Class SimulatorLoggingUtils
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
LoggerConfigConfiguration object of LoggerConfig type
logEventSink
ILogEventSinkA 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
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
SimulatorsResourceSimulators resource
logId
long?Log id to push
checkForSeverityOverride
boolTrue 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