开发者

How to pass context info between NLog loggers?

I would like to be able to pass some context info between NLog loggers in my project. For example id of some logical process so that it gets logged in all loggers from now on so I can easily track it in my logs.

Currently we configure our logger (that is a wrapper around NLog) with some context data 开发者_如何学运维and then pass it between objects that need logging. There must be other/better way. How to do that properly?


I think I've found a solution - Dependency injection with Logger lifestyle set to PerObjectGraph or PerWebRequest or any similar. You configure it in composition root and then just use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜