Interface ILogContext
Represents a logging context that provides methods for creating sub-contexts, retrieving loggers, emitting log messages, and configuring minimum log levels.
public interface ILogContext : IDisposable
- Inherited Members
Properties
Handlers
Gets a list of log handlers.
ILogHandlerList Handlers { get; }
Property Value
Methods
CreateContext()
Creates a new logging context.
ILogContext CreateContext()
Returns
- ILogContext
A new instance of ILogContext.
CreateContext(LogEventLevel)
Creates a new logging context with the specified minimum log level.
ILogContext CreateContext(LogEventLevel minimumLevel)
Parameters
minimumLevelLogEventLevelThe minimum log level for the new context.
Returns
- ILogContext
A new instance of ILogContext with the specified minimum log level.
GetLogger(Type)
Gets a logger for the specified type.
ILogger GetLogger(Type type)
Parameters
typeTypeThe type for which to retrieve the logger.
Returns
GetLogger<T>()
Gets a logger for the specified type.
ILogger GetLogger<T>()
Returns
Type Parameters
TThe type for which to retrieve the logger.
SetLevel(LogEventLevel)
Sets the minimum log level for the current context.
ILogContext SetLevel(LogEventLevel level)
Parameters
levelLogEventLevelThe minimum log level.
Returns
- ILogContext
The current instance of ILogContext with the minimum log level set.
SetLevel(Type, LogEventLevel)
Sets the minimum log level for the specified type in the current context.
ILogContext SetLevel(Type issuer, LogEventLevel level)
Parameters
issuerTypeThe type for which to set the minimum log level.
levelLogEventLevelThe minimum log level.
Returns
- ILogContext
The current instance of ILogContext with the minimum log level set for the specified type.
WithTruncation(int?)
Sets the truncation length for log messages in the current context.
ILogContext WithTruncation(int? length)
Parameters
lengthint?The maximum length of log messages before truncation occurs. Pass null to disable truncation.
Returns
- ILogContext
The current instance of ILogContext with the truncation length set.