Interaction with other Vostok libraries
The main value of Vostok.Logging – integration with other Vostok's libraries.
Logging + Context
Logging.Context lets you say, " Let's automatically add properties from context to this log."
If you use ContextualLogPrefix
, you can do so:
Result:
Logging + Hercules
Logging.Hercules – library is for a log which output events to Hercules.
LogEvent instances are mapped into Hercules events by this rules:
Timestamp
(mandatory) corresponds to:Hercules event build-timestamp - a
UtcDateTime
ofTimestamp
.UtcOffset
tag - along
tag with offset from UTC expressed in 100-ns ticks.
MessageTemplate
--->MessageTemplate
tag ofstring
type.RenderedMessage
--->MessageTemplate
rendered to log string with templates replaced to corresponding values fromProperties
.Properties
dictionary corresponds to a container with the same name. This container contains a tag for each pair. Keys are translated as-is, and the values are handled according to following conventions:If the value is a primitive scalar or a vector of primitive scalars natively supported by Hercules (such as
int
,long
,guid
,string
, etc), it's mapped as-is.Otherwise the value gets converted to
string
: either stringified directly (if it properly overridesToString()
) or serialized to JSON. No further container-like structure is allowed, all values end up being 'flat'.
Exception
object corresponds to a container with the same name and following tags:Exception runtime type (e.g.
System.NullReferenceException
) --->Type
tag of typestring
.Exception message --->
Message
tag of typestring
.Nested exceptions (e.g.
InnerException
andInnerExceptions
forAggregateException
) --->InnerExceptions
tag of typeVector
which contains other exceptions in the same format.Stacktrace of exception --->
StackTrace
tag of typeVector
ofStackFrame
.StackFrame
isContainer
of the following tags which describe a point of code which executed when exception occured:Function
- a name of function (method).Type
- a type whenFunction
is declared.File
- file name.Line
- line number.Column
- column number.
Logging + Tracing
... – library is for adding TraceId to logs.
Last updated