如何关闭log4j2初始化时调试的调试日志记录?
这些事情:
2014-10-22 11:16:45,505 DEBUG Building Plugin [name = filter,class = org.apache.logging.log4j.core.filter.ThresholdFilter]。正在搜索构建器工厂方法...... 2014-10-22 11:16:45,505 DEBUG在类org.apache.logging.log4j.core.filter.ThresholdFilter中找不到构建器工厂方法。试着找一个工厂方法。 2014-10-22 11:16:45,505 DEBUG仍在构建插件[name = filter,class = org.apache.logging.log4j.core.filter.ThresholdFilter]。正在寻找工厂方法......
我通过eclipse从一个简单的Java应用程序调用log4j2。我的意思是: public static void main(String [] args){...}
xml配置的记录器部分是:
<Loggers>
<Root level="trace"/>
<logger name="audit">
<appender-ref ref="AUDITOUT"/>
<appender-ref ref="DEBUGOUT"/>
<appender-ref ref="ORACLEOUTINFO"/>
<appender-ref ref="ORACLEOUTWARN"/>
<appender-ref ref="ORACLEOUTERROR"/>
<appender-ref ref="ORACLEOUTFATAL"/>
</logger>
<logger name="org.apache.log4j">
<appender-ref ref="FILEOUT"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="ORACLEOUTWARN"/>
<appender-ref ref="ORACLEOUTERROR"/>
<appender-ref ref="ORACLEOUTFATAL"/>
</logger>
<logger name="jh.Runner2">
<appender-ref ref="DEBUGOUT"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="ORACLEOUTTRACE"/>
<appender-ref ref="ORACLEOUTDEBUG"/>
<appender-ref ref="ORACLEOUTINFO"/>
<appender-ref ref="ORACLEOUTWARN"/>
<appender-ref ref="ORACLEOUTERROR"/>
<appender-ref ref="ORACLEOUTFATAL"/>
</logger>
</Loggers>
附加目的地:
<Appenders>
<Console name="STDOUT">
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%d %p [%t] - %m%n"/>
</Console>
<RollingFile name="FILEOUT" fileName="${log-path}/mainlog2.log" filePattern="${log-path}/mainlog-%d{yyyy-MM-dd}.log">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%d %p [%t] - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
</RollingFile>
<RollingFile name="DEBUGOUT" fileName="${log-path}/debuglog2.log" filePattern="${log-path}/debuglog-%d{yyyy-MM-dd}.log">
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%d %p %C [%t] - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
</RollingFile>
<RollingFile name="AUDITOUT" fileName="${log-path}/audit2.log" filePattern="${log-path}/auditlog-%d{yyyy-MM-dd}.log">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%d %p [%t] - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
</RollingFile>
<JDBC name="ORACLEOUTTRACE" tableName="J0T_EVENT">
<Filters>
<ThresholdFilter level="DEBUG" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<ConnectionFactory class="com.xxxxxxxxx.db.LoggingDBConnectionFactory" method="getDatabaseConnection" />
<Column name="EVENT_ID" literal="${nextEventID}"/>
<Column name="APP_NM" literal="${appName}"/>
<Column name="CREATE_DT" isEventTimestamp="true"/>
<Column name="EVENT_TYPE_ID" literal="1"/>
<Column name="EVENT_TXT" pattern="${eventTxtPattern}" isUnicode="false"/>
</JDBC>
等
答案 0 :(得分:16)
您的配置以
开头<Configuration status="debug" ...
将此更改为
<Configuration status="warn" ...
并且您只会看到WARN级内部log4j消息(可能是您想要的)。