(SPBackupRestoreLogSeverity, String) del método SPBackupRestoreInformation.Log
Escribe un error, advertencia o mensaje informativo en el archivo de registro de administración.
Espacio de nombres: Microsoft.SharePoint.Administration.Backup
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Sub Log ( _
severity As SPBackupRestoreLogSeverity, _
message As String _
)
'Uso
Dim instance As SPBackupRestoreInformation
Dim severity As SPBackupRestoreLogSeverity
Dim message As String
instance.Log(severity, message)
public void Log(
SPBackupRestoreLogSeverity severity,
string message
)
Parámetros
severity
Tipo: Microsoft.SharePoint.Administration.Backup.SPBackupRestoreLogSeverityUn valor que indica si la message es un error, advertencia, o simplemente informativo.
message
Tipo: System.StringEl mensaje que se registra.
Comentarios
Este método se utiliza principalmente en las implementaciones de los controladores de eventos de la interfaz IBackupRestore .
Ejemplos
El ejemplo siguiente muestra cómo utilizar el método Log en una implementación del método OnRestore .
[C#]
public Boolean OnRestore(Object sender, SPRestoreInformation args)
{
if (args == null)
{
throw new ArgumentNullException("args");
}
// If the CriticalFiles object was deleted from the farm after it was
// backed up, restore it to the configuration database.
CriticalFiles cf = SPFarm.Local.GetChild<CriticalFiles>(this.Name);
if (cf == null)
{
this.Update();
args.Log(SPBackupRestoreLogSeverity.Verbose, this.Name + " added back to configuration database.");
}
Boolean successSignal = true;
// TODO: The following loop restores files to the local server. If there are
// multiple front end servers, your code must iterate through all of
// SPFarm.Local.Servers and restore the same files to every server whose
// Role property is SPServerRole.WebFrontEnd
foreach (String path in FrontEndFilePaths)
{
FileInfo backupCopy = new FileInfo(path);
FileInfo file = new FileInfo(args.Location + @"\" + backupCopy.Name);
try
{
file.CopyTo(path, true);
args.Log(SPBackupRestoreLogSeverity.Verbose, "Restored " + file.Name);
}
catch (Exception e)
{
args.Log(SPBackupRestoreLogSeverity.Verbose, file.Name + " not restored: " + e.Message);
successSignal = false;
}
}
args.CurrentProgress = 50;
return successSignal;
}
Public Function OnRestore(ByVal sender As Object, ByVal args As SPRestoreInformation) As Boolean
If args Is Nothing Then
Throw New ArgumentNullException("args")
End If
' If the CriticalFiles object was deleted from the farm after it was
' backed up, restore it to the configuration database.
Dim cf As CriticalFiles = SPFarm.Local.GetChild(Of CriticalFiles)(Me.Name)
If cf Is Nothing Then
Me.Update()
args.Log(SPBackupRestoreLogSeverity.Verbose, Me.Name & " added back to configuration database.")
End If
Dim successSignal As Boolean = True
' TODO: The following loop restores files to the local server. If there are
' multiple front end servers, your code must iterate through all of
' SPFarm.Local.Servers and restore the same files to every server whose
' Role property is SPServerRole.WebFrontEnd
For Each path As String In FrontEndFilePaths
Dim backupCopy As New FileInfo(path)
Dim file As New FileInfo(args.Location & "\" & backupCopy.Name)
Try
file.CopyTo(path, True)
args.Log(SPBackupRestoreLogSeverity.Verbose, "Restored " & file.Name)
Catch e As Exception
args.Log(SPBackupRestoreLogSeverity.Verbose, file.Name & " not restored: " & e.Message)
successSignal = False
End Try
Next
args.CurrentProgress = 50
Return successSignal
End Function
Vea también
Referencia
clase SPBackupRestoreInformation
Miembros SPBackupRestoreInformation
Espacio de nombres Microsoft.SharePoint.Administration.Backup