SPBackupRestoreInformation.Log - Méthode (SPBackupRestoreLogSeverity, String)
Écrit une erreur, un avertissement ou un message d'information dans le fichier journal d'administration.
Espace de noms : Microsoft.SharePoint.Administration.Backup
Assembly : Microsoft.SharePoint (dans Microsoft.SharePoint.dll)
Syntaxe
'Déclaration
Public Sub Log ( _
severity As SPBackupRestoreLogSeverity, _
message As String _
)
'Utilisation
Dim instance As SPBackupRestoreInformation
Dim severity As SPBackupRestoreLogSeverity
Dim message As String
instance.Log(severity, message)
public void Log(
SPBackupRestoreLogSeverity severity,
string message
)
Paramètres
severity
Type : Microsoft.SharePoint.Administration.Backup.SPBackupRestoreLogSeverityUne valeur qui indique si la message est une erreur, d'avertissement, ou simplement d'information.
message
Type : System.StringLe message est consigné.
Remarques
Cette méthode est principalement utilisée dans les implémentations de gestionnaires d'événements de l'interface IBackupRestore .
Exemples
L'exemple suivant montre comment utiliser la méthode Log dans une implémentation de la méthode 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
Voir aussi
Référence
SPBackupRestoreInformation classe