I started debugging it and to be able to debug the jetty classes I included these as provided dependnencies:
<!-- embedded Jetty dependencies -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-start</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all</artifactId>
<version>${jetty.version}</version>
<scope>provided</scope>
</dependency>
Here's the actual trace:
1) Spring calls servletContext.log();
2) The servletContext class is actually org.eclipse.jetty.webapp.WebappContext so we end up in here: ContextHandler:2040 which has this method:
@Override
public void log(String msg)
{
_
logger.info(msg);
}
3) At this point the _logger is {org.eclipse.jetty.util.log.Slf4jLog}org.slf4j.impl.SimpleLogger(/)
4) I hit F5 to step in that method and I step into this:
public void info(String msg, Object... args)
{
_
logger.info(msg, args);
}
which is in org.eclipse.jetty.util.log.Slf4jLog. At this point the _logger is of type org.slf4j.impl.SimpleLogger. I try to step into this with F5 but Intellij does
not allow me to because it doesn't find this class on the classpath!!!!
Now I'm using the Log4J2 library which has this class (org.slf4j.impl.SimpleLogger) inside the log4j-slf4j-impl.jar I guess Jetty is correctly guessing that SimpleLogger is in the classpath so it tries to use the slf4j, but slf4j is not there - logj42 is. As a result I get two loggings:
----------------------------------------------------------------
[INFO] Log4jServletContainerInitializer starting up Log4j in Servlet 3.0+ environment.
[INFO] Initializing Spring root WebApplicationContext
2014-01-17 16:50:38,486 [main] INFO : Root WebApplicationContext: initialization started
2014-01-17 16:50:38,491 [main] INFO : Refreshing Root WebApplicationContext: startup date [Fri Jan 17 16:50:38 CET 2014]
; root of context hierarchy
----------------------------------------------------------------
As you can see the first lines are from slf4j (via jetty's servletContext.log) and the next ones are from log4j2.
Does anyone have a clue how to fix it?