Source context
Source context is meant to denote the sources of logging events, such as classes calling the log methods. This context also encodes the hierarchy of log's ownership. It is produced with ForContext
method and bound to returned log instance. The dominant use case for source context is to obtain class-based logs:
Structure
Source context exhibits hierarchical structure: chained ForContext
calls produce logs with multiple contexts ordered with respect to calls sequence.
Implementation details
Handling of source context is implementation-specific.
Rendering in text-based logs
Here's an example of how text-based logs render source context:
Sample output from this code:
Last updated