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:

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.

Last updated