Enriches Serilog events with information from the assembly.
To use the enricher, first install the NuGet package:
Install-Package Serilog.Enrichers.AssemblyName
Then, apply the enricher to your LoggerConfiguration
:
Log.Logger = new LoggerConfiguration()
.Enrich.WithAssemblyName()
.Enrich.WithAssemblyVersion()
// ...other configuration...
.CreateLogger();
The WithAssemblyName()
enricher will add an AssemblyName
property to produced events.
The WithAssemblyVersion()
enricher will add an AssemblyVersion
property to produced events.
The WithAssemblyInformationalVersion()
enricher will add an AssemblyInformationalVersion
property to produced events.
The assembly is determined by Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly()
. If you need to specify the assembly, you can provide a type using WithAssemblyName<T>()
.
To use semantic versioning, {version.Major}.{version.Minor}.{version.Build}
, call WithAssemblyVersion(true)
.