LoggingBuilderExtensions Class
HAKOM.Logging.HakomDatabaseLog.Net.Api.Extensions
Section titled “HAKOM.Logging.HakomDatabaseLog.Net.Api.Extensions”Provides extension methods to add database logging to an Microsoft.Extensions.Logging.ILoggingBuilder.
public static class LoggingBuilderExtensionsInheritance System.Object 🡒 LoggingBuilderExtensions
Remarks
Section titled “Remarks”This class is the primary entry point for enabling HAKOM database logging. The AddHakomDatabaseLog(this ILoggingBuilder) method sets up the entire persistence pipeline including storage provider bindings for Oracle, PostgreSQL, and SQL Server.
Methods
Section titled “Methods”LoggingBuilderExtensions.AddHakomDatabaseLog(this ILoggingBuilder) Method
Section titled “LoggingBuilderExtensions.AddHakomDatabaseLog(this ILoggingBuilder) Method”Adds HAKOM database logging to the loggingBuilder.
public static Microsoft.Extensions.Logging.ILoggingBuilder AddHakomDatabaseLog(this Microsoft.Extensions.Logging.ILoggingBuilder loggingBuilder);Parameters
Section titled “Parameters”loggingBuilder Microsoft.Extensions.Logging.ILoggingBuilder
The Microsoft.Extensions.Logging.ILoggingBuilder to add database logging to.
Returns
Section titled “Returns”Microsoft.Extensions.Logging.ILoggingBuilder
The loggingBuilder for chaining.
Exceptions
Section titled “Exceptions”System.ArgumentNullException
Thrown if loggingBuilder is null.
RepositoryConfigurationRequiredForDatabaseLogException
Thrown if no Microsoft.Extensions.Configuration.IConfiguration has been registered with the underlying
IContainer (i.e. configuration has not been set up via
UseConfiguration(this IContainer, Action<IConfigurationBuilder>, bool)).
Remarks
Section titled “Remarks”This method performs the following setup:
- Resolves the Microsoft.Extensions.Configuration.IConfiguration from the container to read repository settings.
- Creates an internal application context with configured repositories and storage provider bindings for Oracle, PostgreSQL, and SQL Server.
- Registers the ISessionFactory and IHakomDatabaseLogStoreFactory as singletons.
- Registers the database logger provider options from the
HakomDatabaseconfiguration section. - Adds the database logger provider to the logging pipeline.
Prerequisites: An Microsoft.Extensions.Configuration.IConfiguration with at least one repository
configured under Persistence:Repositories must be registered with the container before
calling this method. The Logging:HakomDatabase:Repository setting must reference a
configured repository name.
container .UseConfiguration() .UseConfiguredLogging((loggingBuilder) => { loggingBuilder.AddHakomDatabaseLog(); });