Tomcat使用Slf4j和Log4j进行日志记录 [英] Tomcat Logging With Slf4j and Log4j

查看:1000
本文介绍了Tomcat使用Slf4j和Log4j进行日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个部署到 Tomcat 7 服务器的网络应用程序。我的应用程序使用 log4j 文件appender 。但是,并非所有日志消息都会写入文件。

I've got a web-app deployed to a Tomcat 7 server. My application uses log4j and a file appender. However, not all logging messages are getting written to the file.

在我的类路径中,我有:

On my classpath, I have:

log4j-1.2.14.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar

我的 log4j.properties 文件在我的本地计算机上正常运行并正确部署。

My log4j.properties file is working fine on my local machine and is deploy properly.

我看到应用程序生成的错误消息被写入 catalina.out 但没有写入我的 log4j log catalina.out 中的日志消息看起来来自其他一些日志框架,因为输出模式的格式与我的 log4j 模式。我在 catalina.log 中看到的日志记录如下:

I see application generated error messages being written to catalina.out that are not getting written to my log4j log. The log messages in catalina.out look to be coming from some other logging framework because the output pattern is in a different format than my log4j pattern. The logging that I'm seeing in the catalina.log is like:

Nov 4, 2011 11:05:31 AM org.apache.myfaces.shared_impl.util.StateUtils reconstruct
SEVERE

我的log4j模式如下:

And my log4j pattern is like:

2011-11-03 16:42:09,336 ["http-bio-8080"-exec-13] ERROR

我的<$ c中出现了一些记录$ c> log4j 文件日志,但不是全部。根据我的阅读, slf4j 只需要那些罐子来汇集日志输出。有什么想法?

Some logging appears in my log4j file log, but not all of it. From what I've read, slf4j just needs those jars for it to funnel log output. Any ideas?

推荐答案

尝试将jcl-over-slf4j作为依赖项。 myfaces可能正在使用commons-logging。

try including the jcl-over-slf4j as a dependency. myfaces is probably using commons-logging.

检查slf4j文档: http://www.slf4j.org/legacy.html#jcl-over-slf4j

check the slf4j docs: http://www.slf4j.org/legacy.html#jcl-over-slf4j

这篇关于Tomcat使用Slf4j和Log4j进行日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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