Logging Configuration
The logging system can be configured either via file or via options passed to the runtime builder.
File Configuration
The logging system will look for a json file called log-config.json which, if found, will be loaded and applied to any installed logging extension or the default console logging.
The following properties can be applied:
enabled
A boolean that determines if logging is currently enabled. This allows you to ship a pre-defined logging file with your product but have the logging disabled by default
targetFile
Determines the name of the log file used. By default this file will be saved to %LOCALAPPDATA%\OpenFin\Logs. To apply a different path, include an absolute path as well as the file name.
By default, the file name is set to "dotnet-app-.log". The extension determines how the filename filename will be formed but in the case of the SeriLog extension, a timestamp and index will be applied.
For example dotnet-app-20221221_075.log
minLevel
Determines the log level that should be output. All levels above this value will be included.
The allowed values are:
- Verbose
- Debug
- Information
- Warning
- Error
- Fatal
For example if the log level is set to Information (The default) then only log messages output at Information to Fatal will be output.
toConsole
A boolean that determines if log messages should also be output to the console.
traceMessages
A boolean that determines if log messages that involve communication with the runtime should be output.
Note
Due to the large number of messages output, this option should only be enabled if directed by OpenFin support
fileOutputTemplate
A string that determines the output layout of a given log message when writing to a file.
Note
This is currently ignored by the default logging system and is only of use by the SeriLog Extension.
consoleOutputTemplate
A string that determines the output layout of a given log message when writing to the console.
Note
This is currently ignored by the default logging system and is only of use by the SeriLog Extension.
An example of a configuration file:
{
"enabled": true,
"minLevel": "Debug"
}
Builder Configuration
You can also hardcode log settings whilst creating the runtime using the builder using the UseLoggingConfigOverrides() function which must be called before any logging extension is installed.
This supports a subset of the configuration file settings
- Enabled
- TargetFile
- MinLevel
- ToConsole
- RuntimeTraceMessages
runtime = new RuntimeFactory()
.UseLoggingConfigOverrides( new LogConfigOverrides
{
Enabled = true,
MinLevel = LogLevel.Information
} )
.UseSeriLogLogging()
.GetRuntimeInstance(new RuntimeOptions
{
Version = "stable",
UUID = "dotnet-logging-example",
LicenseKey = "your-license-key"
});