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. Syntax

Logging extensions

PreviousSyntaxNextMessage templates

Last updated 3 years ago

provides a wide set of extensions that take care of constructing .

These extensions can be grouped in two ways:

  • By level and name: Debug, Info, Warn, Error, Fatal.

  • By parameters:

    • string:

      • Produces an event with given and no properties.

      • log.Info("Hello, world!");

    • string + T:

      • Produces an event with given and properties of given object.

      • log.Info("Hello, {Who}!", new { Who = "world" });

    • string + object[]:

      • Produces an event with given and given property values (names are inferred from message template).

      • log.Info("Hello, {Who}!", "world");

    • Exception:

      • Produces an event with given exception and no message or properties.

      • log.Error(new Exception());

    • Exception + string:

      • Produces an event with given exception and .

      • log.Error(new Exception(), "I have failed.");

    • Exception + string + T:

      • Produces an event with given exception, and properties of given object.

      • log.Error(new Exception(), "{Who} have/has failed.", new { Who = "I" });

    • Exception + string + object[]:

      • Produces an event with given exception, and given property values (names are inferred from message template).

      • log.Error(new Exception(), "{Who} have/has failed.", "He");

    • interpolated string:

      • Produces an event with given and given property values (names are extracted from argument names).

      • C# 10.

      • var Who = "world";
        log.Info($"Hello, {Who}!");
    • Exception + interpolated string:

      • Produces an event with given exception, and given property values (names are extracted from argument names).

      • C# 10.

      • var Who = "world";
        log.Info(new Exception(), $"Hello, {Who}!");

All extensions produce events with timestamp set to current time and level corresponding to method name.

See the section about to extensions to get a grasp of how to provide values for placeholders in message template.

Abstractions module
log events
message template
message template
message template
message template
message template
message template
message template
Requires
message template
Requires
providing property values