-
Notifications
You must be signed in to change notification settings - Fork 1.4k
AssemblyVersion Layout Renderer
Renders assembly version information from the entry assembly or a named assembly.
Platforms Supported: All
Introduced for ASP.NET / ASP.NET Core in NLog.Web 4.5.0 / NLog.Web.AspNetCore 4.4.0.
${assembly-version:name=string:type=Enum:format=string}
-
Name - Display name of the assembly to retrieve a version from, as determined by its
FullName
property. The assembly will be loaded if needed. If not specified, will use the entry assembly (this did not function correctly for .NET Core until NLog.Web.AspNetCore 4.6). Introduced in NLog 4.3.7. -
Type - Type of the assembly version value to retrieve. Default:
Assembly
.Introduced with NLog v4.5.
Introduced for ASP.NET with NLog.Web / NLog.Web.AspNetCore v4.6.
Possible enum values:
-
Assembly - Assembly version. Value for
AssemblyVersion
attribute.Note: UWP earlier than .NET Standard 1.5 uses value for
ApplicationVersion
-
File - File version. Value for
AssemblyFileVersion
attribute.Notes:
- UWP earlier than .NET Standard 1.5 uses Assembly instead unless a value is given for the
name
parameter
- UWP earlier than .NET Standard 1.5 uses Assembly instead unless a value is given for the
-
Informational - Product Version extracted from
AssemblyInformationalVersion
attribute.Notes:
- UWP earlier than .NET Standard 1.5 uses Assembly instead unless a value is given for the
name
parameter
- UWP earlier than .NET Standard 1.5 uses Assembly instead unless a value is given for the
-
-
Format - Custom format of the assembly version output. Default:
major.minor.build.revision
Supported placeholders are 'major', 'minor', 'build' and 'revision'. The default .NET template for version numbers is 'major.minor.build.revision'. See https://docs.microsoft.com/en-gb/dotnet/api/system.version?view=netframework-4.7.2#remarks for details.Introduced with NLog 4.6
-
Default - Custom value to output when assembly version cannot be found, is empty or matches
0.0.0.0
Introduced with NLog 5.0.2
As this layout renderer uses reflection and version information is unlikely to change during application execution, it is recommended to use it in conjunction with the CachedLayoutRendererWrapper. The entry assembly can't be found in some cases e.g. ASP.NET, unit tests, etc.
Retrieve assembly version for entry assembly:
${assembly-version}
Retrieve assembly version for assembly name NLogAutloadExtension
:
${assembly-version:NLogAutloadExtension}
Retrieve file version for entry assembly:
${assembly-version:type=File}
Retrieve informational version for assembly name NLogAutloadExtension
:
${assembly-version:name=NLogAutloadExtension:type=Informational}
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json