protected void setupLogback ( ) { // Check for Logback config file System Property // http://logback.qos.ch/manual/configuration.html // -Dlogback.configurationFile=logback_prod.xml if ( System . getProperty ( LOGBACK_CONFIGURATION_FILE_PROPERTY ) != null ) { // Logback already configured return ; } // Check for a logback configuration file declared in Fathom settings URL configFileUrl = settings . getFileUrl ( LOGBACK_CONFIGURATION_FILE_PROPERTY , "classpath:conf/logback.xml" ) ; if ( configFileUrl == null ) { throw new FathomException ( "Failed to find Logback config file '{}'" , settings . getString ( LOGBACK_CONFIGURATION_FILE_PROPERTY , "classpath:conf/logback.xml" ) ) ; } LoggerContext context = ( LoggerContext ) LoggerFactory . getILoggerFactory ( ) ; try ( InputStream is = configFileUrl . openStream ( ) ) { JoranConfigurator configurator = new JoranConfigurator ( ) ; configurator . setContext ( context ) ; context . reset ( ) ; configurator . doConfigure ( is ) ; log . info ( "Configured Logback from '{}'" , configFileUrl ) ; } catch ( IOException | JoranException je ) { // StatusPrinter will handle this } StatusPrinter . printInCaseOfErrorsOrWarnings ( context ) ; }
Setup Logback logging by optionally reloading the configuration file .