与glassfish slf4j忽略logback [英] slf4j with glassfish is ignoring logback

查看:170
本文介绍了与glassfish slf4j忽略logback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个java-ee maven项目中,我希望将slf4j与logback一起使用,但是我相信包含来自org.glassfish.extras的'glassfish-embedded-all'工件会导致JDK14LoggerAdapter被使用。



删除此工件会导致日志记录按预期工作,但由于此问题中描述的java-ee api问题导致测试失败 -



我相信导致问题的确切的pom条目是:

 < dependency> 
< groupId> org.glassfish.extras< / groupId>
< artifactId> glassfish-embedded-all< / artifactId>
< version> 3.1< / version>
< scope> test< / scope>
< /依赖关系>

有没有办法配置slf4j来使用logback?或者是否有更好的方法来测试java ee代码?

解决方案

Glassfish Server包含一个SLF4J Binding实现,它也被加载。

如果你用eg打开glassfish jar 7zip你看到有一个org / slf4j / impl / StaticLoggerBinder.class。

在我看来,他们已经为JDK14Logging实现了自己的日志绑定。其他人知道如何禁用此绑定?



另请参阅此链接:使用EJB3.1进行logback


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?

解决方案

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

这篇关于与glassfish slf4j忽略logback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆