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
NDC Support #130
Comments
No plans at the moment, but I'm happy to accept pull requests for it. Not sure how it would work though, seeing as NDC in log4j (java) was meant for multi-threaded environments and node is single-threaded. Any ideas? |
There's this library, which may do what you want: https://github.com/majorleaguesoccer/stacklog |
I would also like to see NDC (or MDC) support of some kind. I initially thinking I'd just hack something together by using unique logger categories, but if you create a logger per connection, the logger instances are leaked because log4js keeps a reference to them. I'll look into stacklog, but I'll need to verify that it doesn't cause the same problem. |
Something like this will be possible in version 2.x - a logger can have context added to it, which will be added to all log events that use that logger. Also log4js no longer keeps references to loggers. The only appender that makes use of the context is the logFaces one at the moment though. |
I have a patch to land MDC support for the 1.x branch. Would it be something you would be willing to accept? |
You should be able to make the same changes to pattern layout in 2.x - the 2.x Logger has support for a context that works much the same as the MDC in that article. Each logEvent will get a copy of the context when it is created. The logFaces appenders make use of the values, so that should give you an example of how to access the fields. I'd rather the feature was added to 2.x - I'm planning to release it to npm very soon (just got a performance problem to look into). Thanks for looking into this, by the way - I'm grateful for any help. If it really has to be included in 1.x for you (perhaps waiting and then upgrading is not an option), let me know and we can work something out. |
I can wait for the new release :) Thanks |
Released in version 2.0.0 |
Backported features for log4js: feat: add line number, column position and filename support log4js-node@5da824e feat(log4js-node#130): Add support for MDC in pattern layout log4js-node@6e15364 feat: add delimiter for fileName depth to %f layout patern log4js-node@e70d132
Backported features for log4js: feat: add line number, column position and filename support log4js-node/log4js-node@5da824e feat(log4js-node#130): Add support for MDC in pattern layout log4js-node/log4js-node@6e15364 feat: add delimiter for fileName depth to %f layout patern log4js-node/log4js-node@e70d132
Backported features for log4js: feat: add line number, column position and filename support log4js-node/log4js-node@5da824e feat(log4js-node#130): Add support for MDC in pattern layout log4js-node/log4js-node@6e15364 feat: add delimiter for fileName depth to %f layout patern log4js-node/log4js-node@e70d132
Hi,
Are there plans to support nested diagnostic contexts?
The text was updated successfully, but these errors were encountered: