简体   繁体   English

限制Eclipse中的Tomcat登录

[英]Restricting Tomcat logging in eclipse

Tomcat logges in eclipse everything starting with DEBUG. Tomcat将从调试开始登录eclipse。 It doesn't log only its own properties but other stuff allow themselves to log (like: 它不仅记录自己的属性,还允许其他东西自己记录(例如:

[localhost-startStop-1] DEBUG oswcsStandardServletEnvironment or [localhost-startStop-1] DEBUG oswcsStandardServletEnvironment
[localhost-startStop-1] DEBUG oscisPathMatchingResourcePatternResolver and many many others). [localhost-startStop-1] DEBUG oscisPathMatchingResourcePatternResolver等。

I want to limit tomcat logging to info or warning. 我想将tomcat日志记录限制为信息或警告。 I tried going into the tomcat directory and changing the log level in logging.propertie from "FINE" to "INFO" to no avail. 我尝试进入tomcat目录,并将logging.propertie的日志级别从“ FINE”更改为“ INFO”无济于事。 I even tried to copy the file into eclipse and appending -Djava.util.logging.config.file=$/Servers/Tomcat v7.0 Server at localhost-config/logging.properties} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager but that didn't help either (and of course I cleaned tomcat many times). 我什至尝试将文件复制到eclipse中,并-Djava.util.logging.config.file=$/Servers/Tomcat v7.0 Server at localhost-config/logging.properties} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager附加到-Djava.util.logging.config.file=$/Servers/Tomcat v7.0 Server at localhost-config/logging.properties} -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager但这也没有帮助(当然,我多次清理了tomcat)。

Also, in web.xml the only place I have the word 'log' not in comment is 另外,在web.xml中,唯一没有注释的单词“ log”是

<mime-mapping>
        <extension>gph</extension>
        <mime-type>application/vnd.flographit</mime-type>
</mime-mapping>

and

<mime-mapping>
        <extension>log</extension>
        <mime-type>text/plain</mime-type>
</mime-mapping>

and my log4j.xml files are configured with either INFO or WARNING , not DEBUG . 和我的log4j.xml文件配置为INFOWARNING ,而不是DEBUG

How can I limit the log to INFO or WARNING , or even just disallow unnecessary classes to log? 如何将日志限制为INFOWARNING ,甚至只是禁止不必要的类进行日志记录?

Tomcat uses Juli logging framework, a mix of Java Util Logging and Apache Commons Logging. Tomcat使用Juli日志记录框架,该框架混合了Java Util日志记录和Apache Commons日志记录。 You can either set the level in the JRE, youre Eclipse is running with ([JRE_DIR]/lib/logging.properties), or you can define your own one, ie copy the former into the Tomcat directory and add this to the run configuration: 您可以在JRE中设置级别,您的Eclipse使用([JRE_DIR] /lib/logging.properties)运行,也可以定义自己的级别,即将前者复制到Tomcat目录并将其添加到运行配置中。 :

Eclipse: "Run" -> "Run Configurations" -> select Tomcat to the left -> select tab "Arguments" to the right -> add this to "VM Arguments": Eclipse:“运行”->“运行配置”->在左侧选择Tomcat->在右侧选择选项卡“ Arguments”->将此添加到“ VM Arguments”:

-Djava.util.logging.config.file=[PATH_TO TOMCAT]\lib\logging.properties

In that file, change these lines: 在该文件中,更改以下行:

.level=INFO

java.util.logging.ConsoleHandler.level = WARNING

Thats it. 而已。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM