Logging Configuration
The logging system can be configured via either a file or options passed to the runtime builder.
File-based configuration
The logging system look for a JSON file called log-config.json which, if found, is loaded and applied to any installed logging extension or the default console logging.
The following properties can be applied:
enabled: A Boolean that determines whether logging is enabled. This property 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 is saved to%LOCALAPPDATA%\OpenFin\Logs. To apply a different path, include an absolute path in addition to the file name. By default, the file name is set todotnet-app-.log. The extension determines how the filename is formed; in the case of the SeriLog extension, a timestamp and index are appended. For exampledotnet-app-20221221_075.logminLevel: Determines the log level to output.
All levels above this value are included. In order of priority, 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 at the Information to Fatal will be written to the log.
toConsole: A Boolean that determines whether log messages are also written to the console.traceMessages: A Boolean that determines whether log messages that involve communication with the runtime are written.
Note
Due to the large number of messages generated by traceMessages, only enable this option if you are directed to by OpenFin Support.
fileOutputTemplate: A string that determines the output layout of a given log message when writing to a file.
Note
The fileOutputTemplate option is ignored by the default logging system and is used only by the SeriLog Extension.
consoleOutputTemplate: A string that determines the output layout of a given log message when writing to the console.
Note
The consoleOutputTemplate is ignored by the default logging system and is used only by the SeriLog Extension.
An example of a configuration file:
{
"enabled": true,
"minLevel": "Debug"
}
Builder Configuration
You can hardcode log settings whilst creating the Runtime using the builder. You do this by using the UseLoggingConfigOverrides() function, which must be called before any logging extension is installed.
This function supports a subset of the configuration file settings
enabledtargetFileminLeveltoConsoleruntimeTraceMessages
runtime = new RuntimeFactory()
.UseLoggingConfigOverrides( new LogConfigOverrides
{
Enabled = true,
MinLevel = LogLevel.Information
} )
.UseSeriLogLogging()
.GetRuntimeInstance(new RuntimeOptions
{
Version = "stable",
UUID = "UUID_STRING",
LicenseKey = "LICENSE_KEY"
});