HAKOM.Logging.HakomDatabaseLog.Net Assembly
This assembly provides a way to write log messages into a HAKOM database.
Remarks
Section titled “Remarks”Some configuration is required to be able to log messages into a database. For basic information on how to configure a HAKOM application, including the various configuration sources like files, environment variables, etc., please refer to the ContainerExtensions in the configuration module.
In order to use HAKOM database logs, there must be at least one repository configured.
This is done in the Persistence:Repositories section.
The documentation for IRepositoryConfiguration describes in detail on how to configure repositories.
In addition, the logger must be configured to use one of the repositories in the Logging:HakomDatabase section.
=== “HAKOM.xml”
<HAKOM> <Logging> <HakomDatabase> <Repository>ExampleRepository</Repository> </HakomDatabase> </Logging></HAKOM>=== “Json”
{ "Logging" : { "HakomDatabase": { "Repository": "ExampleRepository" } }}=== “Environment Variables”
set HAKOM__Logging__HakomDatabase__Repository=ExampleRepository=== “Commandline Parameters”
--HAKOM:Logging:HakomDatabase:Repository=ExampleRepositoryPlease ensure that the repository configured here points to a database that supports HAKOM database logs.
Additional settings of the logger are described here: IHakomDatabaseLoggerOptions
Finally, add the logger to your logging setup
container.UseLogging((loggingBuilder)=>{ loggingBuilder.AddHakomDatabaseLog();});Refer to the ContainerExtensions in the core module for a description of the various methods that can be used to set up logging.
Note that the database logger does not support registration via configuration only like console or file logging, so even when using UseConfiguredLogging(this IContainer, Action<ILoggingBuilder>, string), you must still manually call AddHakomDatabaseLog(this ILoggingBuilder) in the action passed as the second parameter of UseConfiguredLogging(this IContainer, Action<ILoggingBuilder>, string).
Using configuration from a different section
Section titled “Using configuration from a different section”When using a section for configuring logging that is different from the default (“Logging”) the configuration of the database logger must be moved to that section as well.
Given the following configuration file
<HAKOM> <CustomAppConfig> <LogSettings> <File> <LogLevel>Warning</LogLevel> <FileNamePattern>customapp.{timestamp}.log</FileNamePattern> </File> <HakomDatabase> <LogLevel>Critical</LogLevel> <Repository>ExampleRepository</Repository> </HakomDatabase> </LogSettings> </CustomAppConfig></HAKOM>The following code sets up logging to use the configuration from the section above.
container.UseConfiguredLogging((loggingBuilder)=>{ loggingBuilder.AddHakomDatabaseLog();}, "CustomAppConfig:LogSettings");| Namespaces | |
|---|---|
| HAKOM.Logging.HakomDatabaseLog.Net.Api | Contains the public API for writing structured log messages into HAKOM databases. |
| HAKOM.Logging.HakomDatabaseLog.Net.Api.Exceptions | Contains exceptions thrown when database logging cannot be configured or operated correctly. |
| HAKOM.Logging.HakomDatabaseLog.Net.Api.Extensions | Contains extension methods for enabling database logging and managing log sessions. |
| HAKOM.Logging.HakomDatabaseLog.Net.Api.Persistence | Contains interfaces for writing IHakomDatabaseLogEntry instances into database repositories. |