Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off log4j2 startup debug logging

How do I turn off the debug logging that log4j2 spits out when it initialises itself?

These sort of things:

2014-10-22 11:16:45,505 DEBUG Building Plugin[name=filter, class=org.apache.logging.log4j.core.filter.ThresholdFilter]. Searching for builder factory method... 2014-10-22 11:16:45,505 DEBUG No builder factory method found in class org.apache.logging.log4j.core.filter.ThresholdFilter. Going to try finding a factory method instead. 2014-10-22 11:16:45,505 DEBUG Still building Plugin[name=filter, class=org.apache.logging.log4j.core.filter.ThresholdFilter]. Searching for factory method...

I'm calling log4j2 from a simple Java application via eclipse. By that I mean: public static void main(String[] args) { ... }

The loggers portion of the xml config is:

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

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

etc.

like image 437
James Hutchinson Avatar asked Oct 22 '14 10:10

James Hutchinson


People also ask

How do I disable debug log?

In your case you must set logging. level. root on one of level from INFO, WARN, ERROR,FATAL or OFF to turn off all logging.

How do I disable debug logs in spring?

You can also disable Spring Boot's logging configuration entirely by using a value of none . Since logging is initialized before the ApplicationContext is created, it is not possible to control logging from @PropertySources in Spring @Configuration files.


1 Answers

Your configuration starts with

<Configuration status="debug" ...

Change this to

<Configuration status="warn" ...

and you will only see WARN-level internal log4j messages (which is probably what you want).

like image 85
Remko Popma Avatar answered Oct 12 '22 23:10

Remko Popma