Vostok.Context
  • Home
  • Quick Start
  • Interaction with other Vostok libraries
Powered by GitBook
On this page
  • Context + ClusterClient
  • Context + Logging
  • Context + Tracing

Was this helpful?

Interaction with other Vostok libraries

The main value of Vostok.Context – integration with other Vostok libraries.

Context + ClusterClient

Use the ClusterClient.Context, if you want to spread the context across the network. You can look at the example here.

Context + Logging

Logging.Context enables us to say: "Let's automatically add properties from context to that log". If you use ContextualLogPrefix, you can do so:

var log = new ConsoleLog().WithContextualPrefix();

using (new ContextualLogPrefix("op-1"))
{
    log.Info("Message 1!");
    
    using (new ContextualLogPrefix("op-2"))
    {
        log.Info("Message 2!");
    }               
    
    log.Info("Message 3!");
}
ConsoleLog.Flush();

Result:

2018-11-11 16:06:37,970 INFO  [op-1] Message 1!
2018-11-11 16:06:38,047 INFO  [op-1] [op-2] Message 2!
2018-11-11 16:06:38,047 INFO  [op-1] Message 3!

Context + Tracing

__/\_/\__ | 0 0 | / ____ \ |_|_|_|_|_|_|_|

PreviousQuick Start

Last updated 6 years ago

Was this helpful?