Class Factory
Creates loggers and manages the process-wide Serilog configuration.
public static class Factory
- Inheritance
-
Factory
- Inherited Members
Methods
DeInitLogging()
Releases one logging initialization reference and flushes all sinks when the final reference is released.
public static void DeInitLogging()
GetLogger(Type)
Creates a logger whose source context is the supplied type.
public static Logger GetLogger(Type type)
Parameters
typeTypeThe type used as the source context.
Returns
- Logger
A logger for
type.
InitLogging(LoggingOptions, Action<LoggerConfiguration>)
Initializes process-wide logging without a file path.
public static bool InitLogging(Factory.LoggingOptions options, Action<LoggerConfiguration> configure = null)
Parameters
optionsFactory.LoggingOptionsThe default sinks to enable.
configureAction<LoggerConfiguration>An optional callback that can extend the Serilog configuration.
Returns
Remarks
Initialization is reference-counted; balance each call with DeInitLogging().
InitLogging(LoggingOptions, string, int, int, Action<LoggerConfiguration>)
Initializes process-wide logging with rolling-file settings.
public static bool InitLogging(Factory.LoggingOptions options, string loggingFile, int maxFiles = 2, int maxFileSizeKb = 1024, Action<LoggerConfiguration> configure = null)
Parameters
optionsFactory.LoggingOptionsThe default sinks to enable.
loggingFilestringThe output path used when File is enabled.
maxFilesintThe maximum number of retained rolling files.
maxFileSizeKbintThe size limit of each file in kilobytes.
configureAction<LoggerConfiguration>An optional callback that can extend the Serilog configuration.
Returns
Remarks
Initialization is reference-counted; balance each call with DeInitLogging().