Details
- 
    Bug 
- 
    Resolution: Unresolved
- 
    None
- 
    1.7.x
- 
    None
- 
    Operating System: Windows XP 
 Platform: PC
- 
        major
- 
        P1
- 
        291
Description
Log4j-Loggers are cached in static fields.
See org.apache.log4j.Log4jLoggerFactory:
  public static synchronized Logger getLogger(String name) {
    if (log4jLoggers.containsKey(name)) 
else
{ Logger log4jLogger = new Logger(name); log4jLoggers.put(name, log4jLogger); return log4jLogger; }}
A Log4j-Logger caches a reference to a Slf4j-Logger.
See org.apache.log4j.Category:
Category(String name) {
    this.name = name;
    slf4jLogger = LoggerFactory.getLogger(name);
    if (slf4jLogger instanceof LocationAwareLogger) 
}
The problem is that the result of LoggerFactory.getLogger(name) is not cacheable because it could depend on Logback-ContextSelectors. One example: the JNDI-ContextSelector switches between different JNDI-Contexts. If the log4j-over-slf4j bridge jar is installed in a shared classloader the first request to getLogger() would tie the logger to the respective JNDI-Context.
And it is not a solution to move the bridge jar to each web application because the context selector could switch e. g. between users.