HAKOM.Logging.Core.Net Assembly
Provides file-based logging infrastructure and the standard container registration extensions for all HAKOM logging providers.
Remarks
Section titled “Remarks”The assembly contains two main areas of functionality:
- Container-based logging registration — Extension methods on IContainer that allow registering Microsoft.Extensions.Logging.ILoggerProvider instances and configuring them from Microsoft.Extensions.Configuration.IConfiguration sections. See ContainerExtensions for details.
- File logging — A custom Microsoft.Extensions.Logging.ILoggerProvider that writes log messages to files on disk with support for configurable file rotation, encoding, and timestamp formatting. See IFileLoggerOptions and LoggingBuilderExtensions for details.
The simplest way to enable logging is to use UseConfiguredLogging(this IContainer, Action<ILoggingBuilder>, string), which reads the logging configuration from the registered Microsoft.Extensions.Configuration.IConfiguration. This automatically enables Console, File, and Application Insights loggers based on the configuration sections present.
var context = IApplicationContext.Create((container) =>{ container .UseConfiguration() .UseConfiguredLogging();});var context = IApplicationContext.Create((container) =>{ container .UseLogging((loggingBuilder) => { loggingBuilder.AddFile((options) => { options.Path = @"C:\Logs"; options.FileNameTemplate = "myapp.{timestamp}.log"; options.Append = true; }); });});All exceptions thrown by this module inherit from HakomException
and carry unique HK05xxx error codes.
| Namespaces | |
|---|---|
| HAKOM.Logging.Core.Net.Api.Exceptions | Contains exceptions thrown by the logging core module when logging infrastructure cannot be initialized or operated correctly. |
| HAKOM.Logging.Core.Net.Api.Extensions | Extension methods for adding logging to IContainer instances. |
| HAKOM.Logging.Core.Net.Api.File | Contains the public API for file-based logging, including configuration options and extension methods. |
| HAKOM.Logging.Core.Net.Api.File.Exceptions | Contains all exceptions thrown when an error occurs that relates to file logging. |
| HAKOM.Logging.Core.Net.Api.File.Extensions | Extension methods for adding file logging to Microsoft.Extensions.Logging.ILoggingBuilder instances. |
Was this page helpful?Thanks for your feedback!