java Tomcat 和 logback.xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3078842/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:16:17  来源:igfitidea点击:

Tomcat and logback.xml

javatomcatlogback

提问by Petar Minchev

I am starting up a Seam + Hibernate + Logbackproject deployed to Tomcat 6. I use Eclipse as an IDE. Hibernate prints many debug statements, so I have put the level to ERROR, so I don't see them.

我正在启动一个Seam + Hibernate + Logback部署到Tomcat 6. 我使用 Eclipse 作为IDE. Hibernate 打印了许多调试语句,所以我将级别设置为ERROR,所以我看不到它们。

<logger name="org.hibernate">
    <level value="ERROR" />
</logger>

I don't paste my whole logback.xml, because the problem I have, is not connected with its contents.

我不粘贴我的整个logback.xml,因为我遇到的问题与其内容无关。

I have the following classpath problem - If I put the logback.xmlin WEB-INF\classesof my project, it is not found by the classloader and I see all debug statements. On the other hand, if I move the logback.xmlto the libdirectory of Tomcat, everything works perfect and the debug statements are not printed.

我有以下类路径的问题-如果我把logback.xmlWEB-INF\classes我的项目,它不是由类加载器发现,我看到所有的调试语句。另一方面,如果我将 移动logback.xml到 的lib目录Tomcat,则一切正常,并且不会打印调试语句。

But I want to have my logback.xmlinside my project, not in the root libdirectory of Tomcat.

但我想logback.xml在我的项目里面,而不是在libTomcat的根目录中。

And here is my question - isn't the WEB-INF\classesa correct place for logback.xml? Why isn't it found?

这是我的问题 - 不是WEB-INF\classes一个正确的地方logback.xml吗?为什么找不到?

I have always known that the files under the WEB-INF\classesdirectory of the project, are put to the classpath. Thank you for any ideas you have.

一直都知道WEB-INF\classes项目目录下的文件,都是放到classpath下的。感谢您的任何想法。

All the best, Petar

一切顺利,佩塔尔

回答by Igor Mukhin

It looks like your logback.jaris also under ${catalina.home}\lib.

看起来你logback.jar的也在${catalina.home}\lib.

If you want to put your logback.xmlto \WEB-INF\classes, the logback.jarshould be only under \WEB-INF\lib. The ${catalina.home}\lib\logback.jarshould be removed.

如果你想把你的logback.xml\WEB-INF\classeslogback.jar应该只有下\WEB-INF\lib。本${catalina.home}\lib\logback.jar应该被删除。