NLog.Extensions.Logging
Configures NLog through Microsoft Extension Configuration section (Ex from appsettings.json)
Initializes a new instance of the class.
Configuration section to be read
Initializes a new instance of the class.
Configuration section to be read
The to which to apply any applicable configuration values.
Initializes a new instance of the class.
Target-config inside Wrapper-Target
Extension methods to setup LogFactory options
Loads NLog LoggingConfiguration from appsettings.json from NLog-section
Extension methods to setup NLog extensions, so they are known when loading NLog LoggingConfiguration
Setup the MEL-configuration for the ${configsetting} layoutrenderer
Helpers for configuring NLog for Microsoft Extension Logging (MEL)
Enable NLog as logging provider for Microsoft Extension Logging
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
Override configuration and not use default Host Builder Configuration
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
Override configuration and not use default Host Builder Configuration
NLog Logging Provider options
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
NLog Logging Provider options
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging, and loads the new NLog .
New NLog config to be loaded.
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging, and loads the new NLog .
New NLog config to be loaded.
NLog Logging Provider options
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging, and loads NLog config from
relative file-path to NLog configuration file.
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
Initialize NLog LogFactory with NLog LoggingConfiguration.
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
NLog Logging Provider options
Initialize NLog LogFactory with NLog LoggingConfiguration.
ILoggingBuilder for chaining
Enable NLog as logging provider for Microsoft Extension Logging
IServiceCollection for chaining
Enable NLog as logging provider for Microsoft Extension Logging
NLog Logging Provider options
IServiceCollection for chaining
Enable NLog as logging provider for Microsoft Extension Logging
NLog Logging Provider options
Initialize NLog LogFactory with NLog LoggingConfiguration.
IServiceCollection for chaining
Factory method for
Microsoft Extension Configuration
Factory method for
Microsoft Extension Configuration
Layout renderer that can lookup values from Microsoft Extension Configuration Container (json, xml, ini)
Not to be confused with ${appsetting} for lookup of .NET Framework App Settings configuration (app.config / web.config)
Example: appsettings.json
{
"Mode":"Prod",
"Options":{
"StorageConnectionString":"UseDevelopmentStorage=true",
}
}
Config Setting Lookup:
${configsetting:name=Mode} = "Prod"
${configsetting:name=Options.StorageConnectionString} = "UseDevelopmentStorage=true"
${configsetting:name=Options.TableName:default=MyTable} = "MyTable"
Config Setting Lookup Cached:
${configsetting:cached=True:name=Mode}
Documentation on NLog Wiki
Global Configuration Container
Item in the setting container
Name of the Item
The default value to render if the setting value is null.
Renders output that simulates simple Microsoft Console Logger. Useful for Hosting Lifetime Startup Messages.
Documentation on NLog Wiki
Gets or sets format string used to format timestamp in logging messages. Defaults to null.
Gets or sets indication whether or not UTC timezone should be used to format timestamps in logging messages. Defaults to false.
Renders output that simulates Microsoft Json Console Formatter from AddJsonConsole
Documentation on NLog Wiki
Initializes a new instance of the class.
Gets the array of attributes for the "state"-section
Gets or sets whether to include "scopes"-section
Gets or sets whether to include "TraceId" + "SpanId" + "ParentId" from
Similar to ActivityTrackingOptions.TraceId | ActivityTrackingOptions.SpanId | ActivityTrackingOptions.ParentId .
For additional Activity properties, use together with NLog.DiagnosticSource-nuget-package.
Gets or sets whether to include "Timestamp"-section
Helpers for getting the right values from Activity no matter the format (w3c or hierarchical)
Defines EventId capture options
Skip capture
Capture integer as "EventId"-property
Capture string as "EventName"-property
Capture struct as "EventId"-property (with boxing)
Capture integer as "EventId_Id"-property (Legacy)
Capture string as "EventId_Name"-property (Legacy)
Captures legacy properties (EventId-struct + EventId_Id + EventId_Name)
Converts Microsoft Extension Logging BeginScope into NLog ScopeContext
Wrap NLog's Logger in a Microsoft.Extensions.Logging's interface .
Checks if the already parsed input message-parameters must be sent through
the NLog MessageTemplate Parser for proper handling of message-template syntax (Ex. @)
Using the NLog MessageTemplate Parser will hurt performance: 1 x Microsoft Parser - 2 x NLog Parser - 1 x NLog Formatter
Allocates object[]-array for after checking
for mismatch between Microsoft Extension Logging and NLog Message Template Parser
Cannot trust the parameters received from Microsoft Extension Logging, as extra parameters can be injected
Are all parameters positional and correctly mapped?
true if correct
Add Property and init list if needed
list with at least one item
Find max index of the parameters
index, 0 or higher
Is logging enabled for this logger at this ?
Convert log level to NLog variant.
level to be converted.
Begin a scope. Use in config with ${scopeproperty} or ${scopenested}
The state (message)
Creating DI loggers for Microsoft.Extensions.Logging and NLog
New factory with default options
New factory with options.
New factory with options and isolated LogFactory
New factory with provider.
Creates a new instance.
The logger name for messages produced by the logger.
The .
Do nothing
The .
Cleanup
Cleanup
Cleanup
Provider logger for NLog + Microsoft.Extensions.Logging
NLog options
NLog Factory
New provider with default options, see
New provider with options
New provider with options
Optional isolated NLog LogFactory
Create a logger with the name .
Name of the logger to be created.
New Logger
Cleanup
Cleanup
Cleanup
Converts Microsoft Extension Logging ParameterList into NLog MessageTemplate ParameterList
Create a if has values, otherwise null
The LogMessageParameterList-constructor initiates all the parsing/scanning
Verify that the input parameterList contains non-empty key-values and the original-format-property at the end
Extract all valid properties from the input parameterList, and return them in a newly allocated list
Configuration options for the NLog Logging Provider with Microsoft Extension Logging
Control capture of as "EventId"-property.
Default: |
Skip capture of in when default(EventId)
Default:
Separator between for EventId.Id and EventId.Name. Default to _
Only relevant for , or
Enable structured logging by capturing message template parameters with support for "@" and "$". Enables use of ${message:raw=true}
Default:
Enable capture of properties from the ILogger-State-object, both in and
Default:
Enable capture of from the ILogger-State-object. Only relevant when = true
Default:
Use the NLog engine for parsing the message template (again) and format using the NLog formatter
Default:
Enable capture of scope information and inject into
Default:
Shutdown NLog on dispose of the
Default:
Automatically Shutdown NLog on AppDomain.Unload or AppDomain.ProcessExit
Default:
Automatically include , and
Intended for Net5.0 where these properties are no longer included by default for performance reasons
Consider using ${activity} as alternative
Default:
See for documentation
Resets the default Microsoft LoggerFactory Filter for the , and instead only uses NLog LoggingRules.
Default:
Replace Microsoft LoggerFactory with a pure , and disables Microsoft Filter Logic and removes other LoggingProviders.
Can be used as an alternative to calling ILoggingBuilder.ClearProviders(), when only wanting NLog target output.
Default:
Checks the Host Configuration for the specified section-name, and tries to load NLog-LoggingConfiguration after creation of NLogLoggerProvider.
Will only attempt to load NLog-LoggingConfiguration if valid section-name, and NLog-LoggingConfiguration has not been loaded already.
Default: NLog
Enable NLog Targets and Layouts to perform dependency lookup using the Microsoft Dependency Injection IServiceProvider
Default:
Initializes a new instance NLogProviderOptions with default values.
Default options
Forwards NLog LogEvents to Microsoft ILogger-interface with support for NLog Layout-features
Documentation on NLog Wiki
EventId forwarded to ILogger
EventId-Name forwarded to ILogger
Override name of ILogger, when target has been initialized with
Initializes a new instance of the class.
Initializes a new instance of the class.
Microsoft ILogger singleton instance
Initializes a new instance of the class.
Microsoft ILoggerFactory instance
Converts NLog-LogEvent into Microsoft Extension Logging LogState