Tomcat应用程序生成太多日志

时间:2010-04-16 16:44:04

标签: java tomcat6 logging

我有一个在linux ubuntu服务器上运行在tomcat 6.0.20服务器上的应用程序。

它在catalina.out文件夹中生成大量日志,其中大部分是在使用应用程序时生成的,但不是由应用程序生成的。

它生成的一些日志如下所示,

    Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester startElement
FINE: startElement(,,mime-type)
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester startElement
FINE:   Pushing body text '

        '
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester startElement
FINE:   New match='web-app/mime-mapping/mime-type'
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester startElement
FINE:   Fire begin() for CallParamRule[paramIndex=1, attributeName=null, from stack=false]
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester characters
FINE: characters(audio/x-mpeg)
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester endElement
FINE: endElement(,,mime-type)
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester endElement
FINE:   match='web-app/mime-mapping/mime-type'
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester endElement
FINE:   bodyText='audio/x-mpeg'
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester endElement
FINE:   Fire body() for CallParamRule[paramIndex=1, attributeName=null, from stack=false]
Apr 16, 2010 2:55:24 PM org.apache.tomcat.util.digester.Digester endElement
FINE:   Popping body text '

如何关闭它们?这非常重要,因为这是一个生产应用程序。

此致 罗希特夏尔

4 个答案:

答案 0 :(得分:2)

这些语句来自Java的内置记录器(java.util.logger),它出现了。无论出于何种原因,您都可以将您的环境配置为记录“精细”级别的消息。此级别通常用于调试输出,是的,您通常不会将其保留在生产中。

如果我没弄错的话,Tomcat会使用文件conf/logging.properties配置Java记录器。你想在生产中编辑它。有关文件含义的信息在此处:http://java.sun.com/javase/6/docs/technotes/guides/logging/overview.html

但基本上你想在文件中用“INFO”替换“FINE”的出现。

答案 1 :(得分:2)

当logging.properties也有.level = INFO时,我遇到了这个问题。

问题原来是我的一个共享库中也有一个logging.properties(并设置.level = FINEST)。

我通过编辑catalina.properties并确保包含logging.properties的目录是shared.loader类路径中的第一个来修复此问题。

答案 2 :(得分:1)

已经做出了这些改变,但这似乎没有帮助,

I have already changed all the properties to SEVER and INFO, but the logs still keep on generating.

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.FileHandler.level = SEVERE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.

2localhost.org.apache.juli.FileHandler.level = SEVERE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.

3manager.org.apache.juli.FileHandler.level = SEVERE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.

4host-manager.org.apache.juli.FileHandler.level = SEVERE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.

java.util.logging.ConsoleHandler.level = SEVERE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler

# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
#org.apache.catalina.startup.ContextConfig.level = FINE
#org.apache.catalina.startup.HostConfig.level = FINE
#org.apache.catalina.session.ManagerBase.level = FINE
#org.apache.catalina.core.AprLifecycleListener.level=FINE
-- INSERT --                                             

答案 3 :(得分:0)

RUN \ Tomcat 8.0 \ bin \ Tomcat8w.exe 在日志选项卡中,将重定向标准输出更改为空白“”;(默认情况下为“自动”)