在log4j.xml中减少Tomcat Digester记录器的详细程度

时间:2015-08-19 15:05:53

标签: java xml tomcat logging

据我所知,这些晦涩的日志消息与Tomcat的Digester日志记录组件相关联。有谁知道如何减少这些日志的详细程度?

以下调试消息看似无限期地重复,消息之间有100-10,000行,并且由于重复的上下文切换(至于我,)为我正在使用的应用程序的启动时间添加了至少20分钟知道)。除了Digester消息之外没有其他任何痕迹。

这个模糊的调试信息对任何人来说都是正常的吗?

2015-08-19 10:59:30,607 DEBUG [Digester] - <  Fire end() for SetNextRule[methodName=addOperation, pa
ramType=org.apache.tomcat.util.modeler.OperationInfo]>
2015-08-19 10:59:30,607 DEBUG [Digester] - <[SetNextRule]{mbeans-descriptors/mbean/operation} Call o
rg.apache.tomcat.util.modeler.ManagedBean.addOperation(org.apache.tomcat.util.modeler.OperationInfo@
2f64a8b)>
2015-08-19 10:59:30,632 DEBUG [IntrospectionUtils] - <IntrospectionUtils: callMethod1 org.apache.tom
cat.util.modeler.ManagedBean org.apache.tomcat.util.modeler.OperationInfo org.apache.tomcat.util.mod
eler.OperationInfo>
2015-08-19 10:59:30,632 DEBUG [Digester] - <  Fire end() for SetPropertiesRule[]>
2015-08-19 10:59:30,632 DEBUG [Digester] - <  Fire end() for ObjectCreateRule[className=org.apache.t
omcat.util.modeler.OperationInfo, attributeName=null]>
2015-08-19 10:59:30,632 DEBUG [Digester] - <[ObjectCreateRule]{mbeans-descriptors/mbean/operation} P
op org.apache.tomcat.util.modeler.OperationInfo>
2015-08-19 10:59:30,632 DEBUG [sax] - <characters(

    )>
2015-08-19 10:59:30,632 DEBUG [sax] - <startElement(,,operation)>
2015-08-19 10:59:30,632 DEBUG [Digester] - <  Pushing body text '

这是我正在使用的log4j.xml。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender class="org.apache.log4j.ConsoleAppender" name="stdout">
        <layout class="my.log.SyslogPatternLayout">
            <param value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %t %-5p %m%n" name="ConversionPattern"/>
        </layout>
        <filter class="my.log.filter.DynamicLevelFilter">            
            <param name="useJmx" value="true" />
            <param name="baseLogLevelName" value="logging.baselevel.core" />
        </filter>
    </appender>
    <appender class="org.apache.log4j.net.SyslogAppender" name="syslog">
        <param value="LOCAL4" name="facility"/>
        <param value="localhost" name="SyslogHost"/>
        <layout class="my.log.SyslogPatternLayout">
            <param value="{%t} %N{loggingFeature}|%N{loggingComponent} [%D] - %p %m%n" name="ConversionPattern"/>
        </layout>
    </appender>
    <logger name="com.mchange.v2">
        <level value="info"/>
    </logger>
    <logger name="org.hibernate">
        <level value="info"/>
    </logger>
    <logger name="org.springframework">
        <level value="info"/>
    </logger>
    <logger name="net.sf.ehcache">
        <level value="info"/>
    </logger>
    <root>
        <level value="info"/>
        <appender-ref ref="stdout"/>
        <appender-ref ref="syslog"/>
    </root>
</log4j:configuration>

* / tomcat / conf / logging.properties文件包含以下内容:

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

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

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

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

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

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

java.util.logging.ConsoleHandler.level = INFO
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 org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = INFO

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = INFO

调试消息可能如何进入?我甚至不希望这些日志在这里。

1 个答案:

答案 0 :(得分:1)

你想减少tomcat日志记录,这是正确的吗?删除logging.properties文件。从该appender中删除包含org.apache.log4j.net.SyslogAppender的appender。整个。这将禁用您的tomcat日志记录。信息也吐了很多信息就是我所观察到的。