Class LoggingUtils
Utility class for configuring extractor loggers. The logging framework used is Serilog. Loggers are created according to a LoggerConfig configuration object. Log messages contain UTC timestamps.
Inherited Members
Namespace: Cognite.Extractor.Logging
Assembly: Cognite.Logging.dll
Syntax
public static class LoggingUtils
Fields
| Edit this page View SourceLogTemplate
Default logging template without context.
Declaration
public const string LogTemplate = "[{UtcTimestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}"
Field Value
| Type | Description |
|---|---|
| string |
LogTemplateWithContext
Default logging template with context.
Declaration
public const string LogTemplateWithContext = "[{UtcTimestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
Field Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceConfigure(LoggerConfig)
Configure Serilog's shared logger according to the configuration in config.
Use this method only when the static Serilog.Log is used by the application for logging
Declaration
public static void Configure(LoggerConfig config)
Parameters
| Type | Name | Description |
|---|---|---|
| LoggerConfig | config | Configuration object |
GetConfiguration(LoggerConfig)
Creates Serilog.LoggerConfiguration according to the configuration in config
Declaration
public static LoggerConfiguration GetConfiguration(LoggerConfig config)
Parameters
| Type | Name | Description |
|---|---|---|
| LoggerConfig | config | Configuration object of LoggerConfig type |
Returns
| Type | Description |
|---|---|
| LoggerConfiguration | A configured logger |
GetConfiguration(LoggerConfig, LogEventLevel)
Creates Serilog.LoggerConfiguration according to the configuration in config
Declaration
public static LoggerConfiguration GetConfiguration(LoggerConfig config, LogEventLevel baseMinLevel)
Parameters
| Type | Name | Description |
|---|---|---|
| LoggerConfig | config | Configuration object of LoggerConfig type |
| LogEventLevel | baseMinLevel | Base minimum log level. This is overridden by the minimum level in the configuration. You can set this if you want to register external loggers with a lower level than the ones in config. |
Returns
| Type | Description |
|---|---|
| LoggerConfiguration | A configured logger |
GetConfiguredLogger(LoggerConfig)
Creates a Serilog.ILogger logger according to the configuration in config
Declaration
public static ILogger GetConfiguredLogger(LoggerConfig config)
Parameters
| Type | Name | Description |
|---|---|---|
| LoggerConfig | config | Configuration object of LoggerConfig type |
Returns
| Type | Description |
|---|---|
| ILogger | A configured logger |
GetConfiguredLogger(LoggerConfig, LogEventLevel)
Creates a Serilog.ILogger logger according to the configuration in config
Declaration
public static ILogger GetConfiguredLogger(LoggerConfig config, LogEventLevel baseMinLevel)
Parameters
| Type | Name | Description |
|---|---|---|
| LoggerConfig | config | Configuration object of LoggerConfig type |
| LogEventLevel | baseMinLevel | Base minimum log level. This is overridden by the minimum level in the configuration. You can set this if you want to register external loggers with a lower level than the ones in config. |
Returns
| Type | Description |
|---|---|
| ILogger | A configured logger |
GetDefault()
Create a default console logger and returns it.
Declaration
public static ILogger GetDefault()
Returns
| Type | Description |
|---|---|
| ILogger | A ILogger logger with default properties |
GetSerilogDefault()
Create a default Serilog console logger and returns it.
Declaration
public static ILogger GetSerilogDefault()
Returns
| Type | Description |
|---|---|
| ILogger | A Serilog.ILogger logger with default properties |