Vostok.Logging
HomeQuickstartModulesImplementations
1.0.0
1.0.0
  • Home
  • Quickstart
  • Guarantees
  • Configuration
  • Concepts and basics
    • Log interface
    • Log events
    • Syntax
      • Logging extensions
      • Message templates
      • Providing property values
    • Formatting
      • Output templates
      • Special properties
      • Format specifiers
    • Source context
    • Operation context
  • Modules
    • Abstractions
    • Configuration
    • Formatting
    • Console
    • File
    • Hercules
    • Context
    • Serilog
    • Log4net
    • NUnit
    • Microsoft
  • Implementations
    • Silent log
    • Console log
    • File log
    • Hercules log
  • Integrations
    • Serilog integration
    • Log4net integration
    • Microsoft logging integration
  • How-to guides
    • Using operation context
    • Using static log provider
    • Filtering events
    • Enriching events
    • Transforming events
    • Combining multiple logs
    • Custom output templates
    • External configuration rules
Powered by GitBook
On this page
  1. Concepts and basics
  2. Formatting

Format specifiers

PreviousSpecial propertiesNextSource context

Last updated 6 years ago

support providing format specifiers for properties after a semicolon: {prop:format}.

There's generic support for IFormattable values that allows to use format specifiers defined for standard primitives (numeric types, TimeSpan, DateTime, etc.) as well as customize rendering of custom complex types.

Here are some basic examples of property formats:

  • {Timestamp:yy-mm-dd}

  • {RandomDouble:0.###}

Special formats

Whitespace insertion

Ordinary properties can be augmented with one of three special formats to insert surrounding whitespaces:

  • W — inserts a leading whitespace next to property value.

  • w — inserts a trailing whitespace next to property value.

  • wW — inserts both leading and trailing whitespaces next to property value.

Note that no whitespaces are inserted when there's no property with given name in log event. This allows to chain multiple optional properties in the output template and avoid having multiples in rendered message spaces when none of these properties are present.

Log level formats

Special Level property in output templates supports custom formats consisting of case and width.

Allowed case specifiers are u (uppercase), w (lowercase) and t (title case).

Allowed width ranges from 1 to 5.

Here's how the Error value is rendered with different level formats:

  • u5 --> ERROR

  • u3 --> ERR

  • w5 --> error

  • w3 --> err

  • t5 --> Error

  • t3 --> Err

Output templates