• Lexical
Show / Hide Table of Contents
  • Lexical.FileSystem
    • Introduction
    • Abstractions
      • IFileSystem
        • IFileSystem
        • IFileSystemBrowse
        • IFileSystemCreateDirectory
        • IFileSystemDelete
        • IFileSystemFileAttribute
        • IFileSystemMount
        • IFileSystemMove
        • IFileSystemObserve
        • IFileSystemOpen
      • IEvent
      • IEntry
      • IOption
      • IToken
    • FileSystem
    • VirtualFileSystem
    • MemoryFileSystem
    • EmbeddedFileSystem
    • HttpFileSystem
    • Decoration
    • IFileProvider
    • Utility
      • DisposeList
      • FileScanner
      • VisitTree
      • File Operation
  • Lexical.FileProvider
    • Introduction
    • Package
    • Package.Abstractions
    • Root
    • Zip
    • Dll
    • SharpCompress
    • SharpZipLib
    • FileScanner
    • Utils
  • Lexical.Localization
    • Introduction
    • Tutorial
    • Asset
      • IAsset
      • IStringAsset
    • Line
      • ILine
      • ILineFactory
      • ILineRoot
      • ILineFormat
      • ILineLogger
      • LineComparer
    • File
      • ILineReader
      • ILineWriter
      • Ini
      • Json
      • Xml
      • Resx
      • Resources
    • Miscellaneous
      • Plurality
      • ICulturePolicy
      • IStringFormat
      • Dependency Injection
    • Practices
      • Class Library
      • Class Library DI
      • Class Library DI opt.
  • Lexical.Utilities
    • Introduction
    • UnicodeString
    • FileScanner
    • Permutation
    • Tuples
    • StructList

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.

  • json
  • xml
  • ini
"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}"
  }
],
<Loggers name="0">
  <LogLevel>Trace</LogLevel>
  <Output>stdout</Output>
  <Pattern>${message}</Pattern>
</Loggers>

<Loggers name="1">
  <LogLevel>Error</LogLevel>
  <Output>stderr</Output>
  <Pattern>${logger}|${message}|${exception:format=tostring}|${ndc}</Pattern>
</Loggers>

<Loggers name="2">
  <LogLevel>Trace</LogLevel>
  <Output>scabjob.log</Output>
  <Pattern>${date:format=yyyy-MM-dd HH\:mm\:ss}|${level:uppercase=true:format=FirstCharacter}|${logger}|${message}|${ndc}</Pattern>
</Loggers>
[Loggers:0]
LogLevel = Trace
Output = stdout
Pattern = ${message}

[Loggers:1]
LogLevel = Error
Output = stderr
Pattern = ${logger}|${message}|${exception:format=tostring}|${ndc}

[Loggers:2]
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.
Back to top Copyright © 2015-2020 Toni Kalajainen