-
-
Notifications
You must be signed in to change notification settings - Fork 12
Logging
Nano registers the interfaces ILogger
and ILogger<T>
during application startup.
The ILoggingProvider
is registered during startup, and the implementing type defines the logging provider used in the application.
The Logging
section of the configuration defines the behavior and severity of logging in the application.
The section is serialized into an instance of LoggingOptions
, and injected as dependency during startup, thus available for injection throughout the application.
See Appendix - App Settings - Logging for details about the section and the meaning of the variables.
"Logging": {
"LogLevel": "Information",
"LogLevelOverrides":
[
{
"Namespace": "System",
"LogLevel": "Debug"
}
]
}
Nano provides several logging providers (and more added on request), so usually there is no need to implement a custom data provider for your application.
Logging providers implements the interface ILoggingProvider
. It contains a single method Configure(...)
, that is responsible for handling any configuration and setup required for the logging provider.
The logging providers currently supported by Nano, can be referenced in the Appendix - Supported Providers.
The logging provider must be registered as dependencies.
Invoke the method .AddLogging<TProvider>()
, using the logging provider implementation as generic type parameters.
.ConfigureServices(x =>
{
x.AddLogging<SerilogProvider>();
})
When building the logging provider, dependencies related to the logging is configured and initialized.
Nano.Logging.LoggingOptions
Nano.Logging.Interfaces.ILoggingProvider
For a full list of services and dependencies, see Injected Dependencies