carterkozak commented on a change in pull request #475:
URL: https://github.com/apache/logging-log4j2/pull/475#discussion_r598688410
##########
File path:
log4j-slf4j18-impl/src/main/java/org/apache/logging/slf4j/Log4jLoggerFactory.java
##########
@@ -47,8 +47,12 @@ protected Logger newLogger(final String name, final
LoggerContext context) {
@Override
protected LoggerContext getContext() {
- final Class<?> anchor = StackLocatorUtil.getCallerClass(FQCN, PACKAGE);
- return anchor == null ? LogManager.getContext() :
getContext(StackLocatorUtil.getCallerClass(anchor));
+ final Class<?> anchor =
LogManager.getFactory().isClassLoaderDependent()
+ ? StackLocatorUtil.getCallerClass(FQCN, PACKAGE)
+ : null;
+ return anchor == null
+ ? LogManager.getContext()
+ : getContext(StackLocatorUtil.getCallerClass(anchor));
Review comment:
That's what I had in mind. We could provide an overload which takes an
additional integer parameter of additional frames to skip.
I'd prefer to implement that optimization separately from this change, and
also implement another ContextSelector equivalent to `BasicContextSelector` for
fully asynchronous logging so folks don't have to write their own to avoid
classloader lookups.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]