The Autodesk Revit enrichers for Serilog.
Install the Serilog.Enrichers.Autodesk.Revit package from NuGet:
Install-Package Serilog.Enrichers.Autodesk.RevitThen, apply the enricher to you LoggerConfiguration:
// IExternalCommand.Execute
public Result Execute(ExternalCommandData commandData,
out string message,
ElementSet elements) {
UIApplication uiApplication = commandData.Application;
var log = new LoggerConfiguration()
.Enrich.WithRevitVersion(uiApplication)
// other enrichers..
.CreateLogger();
}// IExternalApplication.Execute
public Result OnStartup(UIControlledApplication application) {
var log = new LoggerConfiguration()
.Enrich.WithRevitVersion(application)
// other enrichers...
.CreateLogger();
}The package includes:
WithRevitVersion()- addsApplication.VersionNumberorControlledApplication.VersionNumberWithRevitBuild()- addsApplication.VersionBuildorControlledApplication.VersionBuildWithRevitUserName()- addsApplication.UsernameorControlledApplication.UsernameWithRevitLanguage()- addsApplication.LanguageorControlledApplication.LanguageWithRevitDocumentTitle()- addsDocument.TitleWithRevitDocumentPathName()- addsDocument.PathNameWithRevitDocumentModelPath()- addsDocument.GetCloudModelPath()ifDocument.IsModelInCloudistrueorDocument.GetWorksharingCentralModelPath()ifDocument.IsWorksharedistrueWithRevitAddinId()- addsApplication.ActiveAddinId