protected static boolean initializeLogging ( ) { try { // initial logging config, used before anything else { final URL url = Main . class . getResource ( "log4j-initial.xml" ) ; assert url != null ; DOMConfigurator . configure ( url ) ; } if ( ClassLoaderUtils . IS_WEB_START ) { final URL url = Main . class . getResource ( "log4j-jnlp.xml" ) ; assert url != null ; println ( "Using JNLP log configuration: " + url ) ; DOMConfigurator . configure ( url ) ; return true ; } final File dataCleanerHome = DataCleanerHome . getAsFile ( ) ; if ( initializeLoggingFromDirectory ( dataCleanerHome ) ) { return true ; } if ( initializeLoggingFromDirectory ( new File ( "." ) ) ) { return true ; } // fall back to default log4j.xml file in classpath final URL url = Main . class . getResource ( "log4j-default.xml" ) ; assert url != null ; println ( "Using default log configuration: " + url ) ; DOMConfigurator . configure ( url ) ; return false ; } catch ( final NoClassDefFoundError e ) { // can happen if log4j is not on the classpath println ( "Failed to initialize logging, class not found: " + e . getMessage ( ) ) ; return false ; } }
Initializes logging specifically by looking for log4j . xml or log4j . properties file in DataCleaner s home directory .