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
  • Composing loggers hierarchy
  • Injecting loggers into code
  • Configuring individual loggers

Configuration

This page describes approaches to configuration employed in Vostok.Logging.

Composing loggers hierarchy

There's no such thing as a log factory or log provider: there are just ILog instances, and the only way to get one initially is to instantiate one of the available implementations in code. Everything else is achieved with decorator-based extensions and interface methods:

  • Combining multiple logs into one.

  • Filtering incoming events.

  • Enriching incoming events with properties.

  • Obtaining log instances tied to specific source context.

This approach may look unfamiliar to prior log4net users experienced with XML configuration files. Indeed, it lacks additional flexibility offered by file-based configs but enables much easier setup for new applications.

Injecting loggers into code

It's preferable to inject log instances explicitly through constructors, either using a DI container or simply passing them manually. Static log provider may be sufficient for simple applications, though.

Configuring individual loggers

Individual log instances (such as console log or file log) are typically configured in code by passing a settings object. However, some implementations (namely file log) also accept an arbitrary settings provider delegate that can be used to configure from external sources using Vostok.Configuration library.

Also, simple filtering and enrichment rules can be supplied from external configuration.

PreviousGuaranteesNextConcepts and basics

Last updated 5 years ago