Logging Levels

As already mentioned in section Logging Level of chapter General Settings, an extension is available that allows to change the display text of each logging level. This chapter wants to show how to change these values. But be aware, changing the display text of a particular logging level does have global impact!

Display Text Registration

Modifying the display text of any of the logging levels is pretty easy. The only thing to do is to include namespace Plexdata.LogWriter.Extensions and to call method RegisterDisplayText() with the new display text. See code snippet below how to change the display text values of all logging levels into three–letter–abbreviations.

Copy
LogLevel.Trace.RegisterDisplayText("TRC");
LogLevel.Debug.RegisterDisplayText("DBG");
LogLevel.Verbose.RegisterDisplayText("INF");
LogLevel.Message.RegisterDisplayText("MSG");
LogLevel.Warning.RegisterDisplayText("WRN");
LogLevel.Error.RegisterDisplayText("ERR");
LogLevel.Fatal.RegisterDisplayText("FTL");
LogLevel.Critical.RegisterDisplayText("CRT");

With the above changes in mind, from now all written logging message would look like as shown below.

2021-05-23 17:23:05.1234;TRC;Trace...
2021-05-23 17:23:05.1234;DBG;Debug...
2021-05-23 17:23:05.1234;INF;Verbose...
2021-05-23 17:23:05.1234;MSG;Message...
2021-05-23 17:23:05.1234;WRN;Warning...
2021-05-23 17:23:05.1234;ERR;Error...
2021-05-23 17:23:05.1234;FTL;Fatal...
2021-05-23 17:23:05.1234;CRT;Critical...

Restore Display Defaults

Restoring the default values of the display text of each logging level is as easy as to change them. See following code snippet how to restore the display text of each of the logging levels.

Copy
LogLevel.Trace.RestoreDisplayText();
LogLevel.Debug.RestoreDisplayText();
LogLevel.Verbose.RestoreDisplayText();
LogLevel.Message.RestoreDisplayText();
LogLevel.Warning.RestoreDisplayText();
LogLevel.Error.RestoreDisplayText();
LogLevel.Fatal.RestoreDisplayText();
LogLevel.Critical.RestoreDisplayText();

Back at defaults, from now all written logging message would look like as shown below.

2021-05-23 17:23:05.1234;TRACE;Trace...
2021-05-23 17:23:05.1234;DEBUG;Debug...
2021-05-23 17:23:05.1234;VERBOSE;Verbose...
2021-05-23 17:23:05.1234;MESSAGE;Message...
2021-05-23 17:23:05.1234;WARNING;Warning...
2021-05-23 17:23:05.1234;ERROR;Error...
2021-05-23 17:23:05.1234;FATAL;Fatal...
2021-05-23 17:23:05.1234;CRITICAL;Critical...