Logging from Command-Line
Tool needs logging to be opt-in. This way the output stream can be chosen to be used for logging or for outputting localization lines.
-l adds default logging to console. This is same as -l:stdout.
Lexical.Localization.Tool -l
-l:stderr adds logging to standard error stream.
Lexical.Localization.Tool -l:stderr
-l:filename.log adds logging to a file filename.log.
Lexical.Localization.Tool -l:filename.log
-e enables logging of errors to standard error stream. This is same as -e:stderr.
Lexical.Localization.Tool -e
-e:filename.log enables logging of errors to a file.
Lexical.Localization.Tool -e:filename.log
-v adds verbosity to log lines, and more detailed messages.
Lexical.Localization.Tool -v
Levers can be coalesced. -lev adds logging (l) of messages and errors (e) with verbosity (v).
Lexical.Localization.Tool -lev
Logging Configuration
Configuration files have "Loggers" section, which contain an array of individual loggers.
"Loggers": [
{
"LogLevel": "Trace",
"Output": "stdout",
"Pattern": "${message}"
},
{
"LogLevel": "Error",
"Output": "stderr",
"Pattern": "${logger}|${message}|${exception:format=tostring}|${ndc}"
},
{
"LogLevel": "Trace",
"Output": "scabjob.log",
"Pattern": "${date:format=yyyy-MM-dd HH\\:mm\\:ss}|${level:uppercase=true:format=FirstCharacter}|${logger}|${message}|${ndc}"
}
],
Log Level
LogLevel defines the lowest severity that will be appended to the log. Definitions from Microsoft.Extensions.Logging.
LogLevel | Description |
---|---|
None | Not used for writing log messages. |
Critical | Unrecoverable application or system crash. |
Error | When the current flow of execution is stopped due to a failure. |
Warning | An unexpected event in the application flow, but do not cause the application to stop. |
Information | Track the general flow of the application. |
Debug | Used for development. |
Trace | Contain the most detailed messages. |
Output
Output defines where to write the log lines.
Output | Description |
---|---|
stdout | Logger appends to standard output pipe. |
stderr | Logger appends to standard error pipe. |
filename.ext | Logger appends to file. |
Pattern
Pattern is a string that consists of layout renderers. (From NLog).
Pattern | Description |
---|---|
${logger} | The logger name. |
${message} | The formatted log message. |
${exception} | Exception information. |
${ndc} | Nested Diagnostics Context information. |
${level} | Log level of the event. |
${date} | Current date and time. |
${longdate} | The date and time in a long, sortable format: yyyy-MM-dd HH:mm:ss.ffff. |
${shortdate} | The short date in a sortable format: yyyy-MM-dd. |
${ticks} | The Ticks value of current date and time. |
${time} | The time in a 24-hour, sortable format: HH:mm:ss.mmm. |
${counter} | Incremental counter for each log line. |
${guid} | Random GUID. |