|
|
|
|
|
by wsargent
2161 days ago
|
|
Agree with everything you've said, but MDC does have one big drawback: it's only convenient when you're working within a single thread. If you're writing asynchronous code (Scala, Akka, Vert.x etc) then MDC doesn't help you very much. [1] I generally find it easier to have an explicit "context" object and pass that around in an operation, and then log once that context has been built up. If you're lucky, the logging framework will do that for you. Bunyan did this the Right Way from the get go, using `log.child`. [2] [1] https://tersesystems.github.io/blindsight/usage/context.html... [2] https://github.com/trentm/node-bunyan#logchild |
|