slf4j with glassfish is ignoring logback

爷,独闯天下 提交于 2020-01-02 08:28:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!