-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add context on logger level #1615
Comments
Logger already provides us with a class name when we render a message. But what if I want to identify which instance of the class a message comes from? I think it would be very useful if this feature allowed us to attach a context data that was visible only for messages logged from a certain instance of the class. So we could attach some data that identifies a class instance in a readable way. I'm not sure how it can be implemented though since a Logger is usually a static member and we never pass |
By the way does |
it's cached by name, for performance reasons
You mean that the context data should be cleared when the Logger instance is out of scope? Manually resetting isn't a good solution? |
I was hoping to achieve something like this:
So that there is a way to distinguish between messages emitted by a different class instances and probably to route them to different log files if I want to. After some googling I figured out that I can just construct a differently named Logger for each class instance (I'm new to NLog). But when transactionId is embedded in Logger name string it feels that I'm doing it wrong. |
Another work around is to use the MLDC and prefix with the logger /class name? |
Feature:
We like to do:
rendering, something like this:
LDC? "logger diagnostic context"
The text was updated successfully, but these errors were encountered: