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
  • SerilogLog
  • VostokSink
  1. Integrations

Serilog integration

PreviousIntegrationsNextLog4net integration

Last updated 5 years ago

Location: module.

SerilogLog

var serilogAdapter = new SerilogLog(serilogLogger);

SerilogLog is an adapter that wraps an arbitrary instance of Serilog's ILogger and implements Vostok . It enables gradual migration for Serilog users by allowing existing code to be ported to Vostok ILog abstraction without immediately changing and reconfiguring underlying implementation.

It preserves message templates in their original form as Serilog's templating syntax is a superset of Vostok capabilites. Properties are also passed as-is, bound by provided Serilog logger instance.

ForContext method works exactly like it does in native : it causes returned log instances to enrich incoming log events with SourceContext property containing a hierarchical context value. See section for more details.

VostokSink

VostokSink is an implementation of Serilog's ILogEventSink interface based on an arbitrary Vostok ILog instance.

var vostokSink = new VostokSink(vostokLog);

var serilogLogger = new LoggerConfiguration()
    .WriteTo.Sink(vostokSink, LogEventLevel.Verbose)
    .CreateLogger();
serilog
log interface
message templates
implementations
source context