carterkozak commented on a change in pull request #475:
URL: https://github.com/apache/logging-log4j2/pull/475#discussion_r595570063
##########
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:
In the case where the context selector is classloader dependent, I
imagine we could merge the `anchor = StackLocatorUtil.getCallerClass(FQCN,
PACKAGE)` and `StackLocatorUtil.getCallerClass(anchor)` calls into a single
sweep, potentially cutting the work in half.
----------------------------------------------------------------
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]