rgoers commented on issue #71:
URL:
https://github.com/apache/logging-log4j-kotlin/issues/71#issuecomment-2002548717
@rocketraman I guess I am not grasping at all what you want. With my PR you
can now do:
```
class T {
private static final Logger log = LogManger.getLogger(T.class);
R r = new R();
doSomethingInThread() {
ScopedContext.newInstance().where("context", "thread").run(() -> {
r.doSomethingOnResource();
log.info{ "bar");
});
}
}
class R {
private static final Logger log = LogManger.getLogger(R.class);
fun doSomethingOnResource() {
log.info("context will be 'thread' here);
ScooedContext.newInstance().where("context", "resource").run(() -> {
log.info { "foo" };
)};
}
}
```
so everything inside the run method, and only inside the run method contains
the data. In the example above the value of context will vary depending on
which ScopedContext you are executing in. Isn't this what you wanted?
Note, that while the PR uses a ThreadLocal it has to do that to make it
thread-safe. Each Thread has its own stack of contexts.
Now it would be great if instead you could annotate the class or method with
the scope but due to their limitations I am not sure how you could actually
populate the context since properties associated with annotations have to be
known at compile time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]