本文介绍了weblogic下的sl4j/logback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Weblogic12下配置sl4j/logback.我部署了包含war文件的耳文件,该文件具有WEB-INF \ classes \ logback.xml
这是配置:

I'm trying to configure sl4j/logback under Weblogic12.I deploy ear file, which has war file, which has WEB-INF\classes\logback.xml
Here is the config:

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<root level="debug">
    <appender-ref ref="STDOUT" />
</root>

</configuration>

我要登录的代码:

private static final Logger logger = LoggerFactory.getLogger(FrontEndServlet.class);
//......
logger.info("info test");
logger.debug("debug test");
logger.error("error test");

我在标准输出中看到的是:

What I see in the standart output is :

ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
INFO: info test
ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
SEVERE: error test

因此,似乎未拾取配置文件.我究竟做错了什么?

So, it looks like config file is not picked up.What am I doing wrong?

推荐答案

问题是-sl4j没有执行回滚,而是使用了Weblogic的slf4j-jdk日志记录.可以使用Weblogic的配置 weblogic-application.xml ,选项 prefer-application-packages

The problem was - sl4j did not pick up logback and used Weblogic's slf4j-jdk logging instead. Can be fixed with Weblogic's config weblogic-application.xml, option prefer-application-packages

这篇关于weblogic下的sl4j/logback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 20:13