Table of Contents

Class SimulatorLoggingUtils

Namespace
Cognite.Simulator.Utils
Assembly
Cognite.Simulator.Utils.dll

Utility class for configuring simulator loggers. The logging framework used is Serilog. Loggers are created according to a LoggerConfig configuration object. Log messages contain UTC timestamps.

public static class SimulatorLoggingUtils
Inheritance
SimulatorLoggingUtils
Inherited Members

Methods

FlattenDictionary(Dictionary<string, string>)

Flattens a dictionary into a string representation.

public static string FlattenDictionary(Dictionary<string, string> dict)

Parameters

dict Dictionary<string, string>

The dictionary to flatten.

Returns

string

A string representation of the dictionary.

GetConfiguredLogger(LoggerConfig, ILogEventSink)

Creates a Serilog.ILogger logger according to the configuration in config

public static ILogger GetConfiguredLogger(LoggerConfig config, ILogEventSink logEventSink)

Parameters

config LoggerConfig

Configuration object of LoggerConfig type

logEventSink ILogEventSink

A custom log event sink to write logs to

Returns

ILogger

A configured logger

GetDefault()

Create a default console logger and returns it.

public static ILogger GetDefault()

Returns

ILogger

A ILogger logger with default properties

GetLogEnrichers(SimulatorsResource, long?, bool)

Used to enrich log events with the simulator log id and min severity. Example usage: LogContext.Push(await GetLogEnrichers(_cdfSimulatorResources, logId).ConfigureAwait(false))

public static Task<PropertyEnricher[]> GetLogEnrichers(SimulatorsResource cdf, long? logId, bool checkForSeverityOverride = false)

Parameters

cdf SimulatorsResource

Simulators resource

logId long?

Log id to push

checkForSeverityOverride bool

True to check for severity override

Returns

Task<PropertyEnricher[]>

GetSerilogDefault()

Create a default Serilog console logger and returns it.

public static ILogger GetSerilogDefault()

Returns

ILogger

A Serilog.ILogger logger with default properties