Skip to content
Documentation

LoggerExtensions Class

Adds extension methods to Microsoft.Extensions.Logging.ILogger for database logging specific calls.

public static class LoggerExtensions

Inheritance System.Object 🡒 LoggerExtensions

This class provides two key extensions: BeginSession(this ILogger) for managing logging sessions, and LogProgress(this ILogger, string, object[]) for writing progress-level entries.

LoggerExtensions.BeginSession(this ILogger) Method

Section titled “LoggerExtensions.BeginSession(this ILogger) Method”

Starts a new logging Session by calling Microsoft.Extensions.Logging.ILogger.BeginScope<>(@@0) with a freshly created Session as the state.

public static System.IDisposable? BeginSession(this Microsoft.Extensions.Logging.ILogger logger);

logger Microsoft.Extensions.Logging.ILogger

The Microsoft.Extensions.Logging.ILogger to start a session for.

System.IDisposable
An System.IDisposable that ends the session when disposed, or null if the logger does not support scopes.

System.ArgumentNullException
Thrown if logger is null.

When the logger is a HAKOM database logger, the session is created through the registered ISessionFactory and tracked by the scope provider. When the returned System.IDisposable is disposed, a “Session closed” log entry is written automatically and the session is marked inactive.

When the logger is not a HAKOM database logger (e.g. a console or file logger), a Session with a random System.Guid is created and passed as a regular scope state. No database-specific behavior occurs in this case.

using (logger.BeginSession())
{
logger.LogInformation("Import started");
// ... do work ...
logger.LogInformation("Import completed");
}

LoggerExtensions.LogProgress(this ILogger, string, object[]) Method

Section titled “LoggerExtensions.LogProgress(this ILogger, string, object[]) Method”

Writes a progress-level log entry by calling Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger,Microsoft.Extensions.Logging.LogLevel,System.String,System.Object[]) with Microsoft.Extensions.Logging.LogLevel.None.

public static void LogProgress(this Microsoft.Extensions.Logging.ILogger logger, string message, params object[]? args);

logger Microsoft.Extensions.Logging.ILogger

The Microsoft.Extensions.Logging.ILogger to write the progress entry to.

message System.String

The message to log. Supports positional format placeholders.

args System.Object[]

Optional array of parameters to substitute into the message template.

System.ArgumentNullException
Thrown if logger is null.

Progress entries map to the legacy HAKOM LogType.Progress (value 3) in the database. They are intended for tracking the progress of long-running operations and are distinct from informational, warning, or error messages.

The message parameter supports the standard .NET logging message template syntax with positional placeholders (e.g. "Processing item {0} of {1}").

© 2026 Volue.Version v0.6.38017 November 2026