问题
In a java-ee maven project I have I'm wanting to use slf4j with logback, however I believe inclusion of the 'glassfish-embedded-all' artifact from org.glassfish.extras is causing the JDK14LoggerAdapter to be used instead.
Removing this artifact causes the logging to work as expected, however causes test failures due to java-ee api issues as described on this question - Testing against Java EE 6 API.
The exact pom entry causing the problem, I believe, is:
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
Is there a way to configure slf4j to use logback? Or is there a better way of testing java ee code?
回答1:
The Glassfish Server includes an SLF4J Binding implementation which is also loaded.
If you open the glassfish jar with e.g. 7zip you see there is a org/slf4j/impl/StaticLoggerBinder.class.
In my point of view they have implemented their own logging binder for JDK14Logging. Does anyone else know how to disable this Binding?
Also see this link: logback with EJB3.1
来源:https://stackoverflow.com/questions/10474042/slf4j-with-glassfish-is-ignoring-logback