rgoers commented on a change in pull request #475:
URL: https://github.com/apache/logging-log4j2/pull/475#discussion_r598352032
##########
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:
You would have to make a new method that gets the caller of the caller.
It might be more efficient. In Java 8 you could continue searching from the
last index. In Java 9+ you could continue processing the stream.
--
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]