public static void setLogLevels ( final int aLogLevel , final String [ ] aLoggerList , final String [ ] aExcludesList , final String ... aIncludesList ) { final ArrayList < String > loggerList = new ArrayList <> ( Arrays . asList ( aLoggerList ) ) ; final Class < ? extends Logger > simpleLogger = LoggerFactory . getLogger ( "org.slf4j.impl.SimpleLogger" ) . getClass ( ) ; if ( aIncludesList != null ) { loggerList . addAll ( Arrays . asList ( aIncludesList ) ) ; } for ( final String loggerName : loggerList ) { if ( aExcludesList != null ) { boolean skip = false ; for ( final String element : aExcludesList ) { if ( loggerName . equals ( element ) ) { skip = true ; break ; } } if ( skip ) { continue ; } } final Logger loggerObject = LoggerFactory . getLogger ( loggerName ) ; final Class < ? extends Logger > loggerClass = loggerObject . getClass ( ) ; if ( simpleLogger . equals ( loggerClass ) ) { try { final Field field = loggerClass . getDeclaredField ( "currentLogLevel" ) ; field . setAccessible ( true ) ; field . setInt ( loggerObject , aLogLevel ) ; if ( loggerObject . isDebugEnabled ( ) ) { LOGGER . debug ( MessageCodes . MVN_012 , loggerName , getLevelName ( aLogLevel ) ) ; } } catch ( NoSuchFieldException | IllegalAccessException details ) { LOGGER . error ( MessageCodes . MVN_011 , details ) ; } } else { LOGGER . warn ( MessageCodes . MVN_010 , loggerName ) ; } } }
Sets the logging level of the supplied loggers optionally excluding some and including others .