限制日志中的Tomcat日志 [英] Restricting Tomcat logging in eclipse

查看:167
本文介绍了限制日志中的Tomcat日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tomcat会记录从DEBUG开始的所有内容。它不记录自己的属性,但其他东西允许自己记录(如:



[localhost-startStop-1] DEBUG oswcsStandardServletEnvironment

[localhost-startStop-1] DEBUG oscisPathMatchingResourcePatternResolver 和许多其他)。



我想将tomcat日志记录限制为信息或警告。我尝试进入tomcat目录,并将 logging.propertie 中的日志级别从FINE更改为INFO无效。我甚至尝试将文件复制到eclipse并在localhost-config / logging.properties中添加 -Djava.util.logging.config.file = $ / Servers / Tomcat v7.0 Server} -Djava.util .logging.manager = org.apache.juli.ClassLoaderLogManager 但这并没有帮助(当然我也多次清理tomcat)。



此外,在web.xml中,唯一没有发表评论的'log'单词是

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

 < MIME映射> 
< extension> log< / extension>
< mime-type> text / plain< / mime-type>
< / mime-mapping>

和我的 log4j.xml INFO 警告,而不是 DEBUG p>

如何将日志限制为 INFO 警告或者甚至只是禁止不必要的类记录?

解决方案

Tomcat使用Juli日志框架,Java Util Logging和Apache Commons Logging 。您可以设置JRE中的级别,即Eclipse正在运行([JRE_DIR] /lib/logging.properties)),也可以定义自己的级别,即将前者复制到Tomcat目录中,并将其添加到运行配置:



Eclipse:运行 - >运行配置 - >选择Tomcat到左侧 - >选择选项卡参数在右侧 - >添加到 VM参数:

  -Djava.util.logging.config.file = [PATH_TO TOMCAT] \lib\logging。属性

在该文件中,更改以下行:

  .level = INFO 

java.util.logging.ConsoleHandler.level = WARNING

这是它。


Tomcat logges in eclipse everything starting with DEBUG. It doesn't log only its own properties but other stuff allow themselves to log (like:

[localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment or
[localhost-startStop-1] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver and many many others).

I want to limit tomcat logging to info or warning. I tried going into the tomcat directory and changing the log level in logging.propertie from "FINE" to "INFO" to no avail. 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).

Also, in web.xml the only place I have the word 'log' not in comment is

<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.

How can I limit the log to INFO or WARNING, or even just disallow unnecessary classes to log?

解决方案

Tomcat uses Juli logging framework, a mix of Java Util Logging and Apache Commons Logging. 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, i.e. copy the former into the Tomcat directory and add this to the run configuration:

Eclipse: "Run" -> "Run Configurations" -> select Tomcat to the left -> select tab "Arguments" to the right -> add this to "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.

这篇关于限制日志中的Tomcat日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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