private void reconfigure ( ) throws ConfigurationException , FileNotFoundException { Properties consolidatedProps = getConsolidatedProperties ( ) ; logger . info ( "The root category for log4j.rootCategory now is {}" , consolidatedProps . getProperty ( LOG4J_ROOT_CATEGORY ) ) ; logger . info ( "The root category for log4j.rootLogger now is {}" , consolidatedProps . getProperty ( LOG4J_ROOT_LOGGER ) ) ; // Pause the async appenders so that the appenders are not accessed for ( String originalAppenderName : originalAsyncAppenderNameMap . keySet ( ) ) { MessageBatcher asyncBatcher = BatcherFactory . getBatcher ( AsyncAppender . class . getName ( ) + "." + originalAppenderName ) ; if ( asyncBatcher == null ) { continue ; } asyncBatcher . pause ( ) ; } // Configure log4j using the new set of properties configureLog4j ( consolidatedProps ) ; // Resume all the batchers to continue logging for ( String originalAppenderName : originalAsyncAppenderNameMap . keySet ( ) ) { MessageBatcher asyncBatcher = BatcherFactory . getBatcher ( AsyncAppender . class . getName ( ) + "." + originalAppenderName ) ; if ( asyncBatcher == null ) { continue ; } asyncBatcher . resume ( ) ; } }
Reconfigure log4j at run - time .