Tomcat使用Slf4j和Log4j进行日志记录

编程入门 行业动态 更新时间:2024-10-25 13:20:46
本文介绍了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

我的 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文档: www.slf4j/legacy.html#jcl-over-slf4j

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

更多推荐

Tomcat使用Slf4j和Log4j进行日志记录

本文发布于:2023-11-25 03:58:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日志   Tomcat   Slf4j   Log4j

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!