private static synchronized boolean isLog4JConfigured ( ) { if ( ! log4jConfigured ) { Enumeration en = org . apache . log4j . Logger . getRootLogger ( ) . getAllAppenders ( ) ; if ( ! ( en instanceof org . apache . log4j . helpers . NullEnumeration ) ) { log4jConfigured = true ; } else { Enumeration cats = LogManager . getCurrentLoggers ( ) ; while ( cats . hasMoreElements ( ) ) { org . apache . log4j . Logger c = ( org . apache . log4j . Logger ) cats . nextElement ( ) ; if ( ! ( c . getAllAppenders ( ) instanceof org . apache . log4j . helpers . NullEnumeration ) ) { log4jConfigured = true ; } } } if ( log4jConfigured ) { String msg = "Log4J is already configured, will not search for log4j properties file" ; LoggerFactory . getBootLogger ( ) . info ( msg ) ; } else { LoggerFactory . getBootLogger ( ) . info ( "Log4J is not configured" ) ; } } return log4jConfigured ; }
Helper method to check if log4j is already configured