@ -31,7 +31,6 @@ import org.springframework.boot.logging.AbstractLoggingSystem;
import org.springframework.boot.logging.LogFile ;
import org.springframework.boot.logging.LogFile ;
import org.springframework.boot.logging.LogLevel ;
import org.springframework.boot.logging.LogLevel ;
import org.springframework.boot.logging.LoggerConfiguration ;
import org.springframework.boot.logging.LoggerConfiguration ;
import org.springframework.boot.logging.LoggerConfigurationComparator ;
import org.springframework.boot.logging.LoggingInitializationContext ;
import org.springframework.boot.logging.LoggingInitializationContext ;
import org.springframework.boot.logging.LoggingSystem ;
import org.springframework.boot.logging.LoggingSystem ;
import org.springframework.util.Assert ;
import org.springframework.util.Assert ;
@ -49,9 +48,6 @@ import org.springframework.util.StringUtils;
* /
* /
public class JavaLoggingSystem extends AbstractLoggingSystem {
public class JavaLoggingSystem extends AbstractLoggingSystem {
private static final LoggerConfigurationComparator COMPARATOR = new LoggerConfigurationComparator (
"" ) ;
private static final LogLevels < Level > LEVELS = new LogLevels < Level > ( ) ;
private static final LogLevels < Level > LEVELS = new LogLevels < Level > ( ) ;
static {
static {
@ -122,8 +118,10 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
@Override
@Override
public void setLogLevel ( String loggerName , LogLevel level ) {
public void setLogLevel ( String loggerName , LogLevel level ) {
Assert . notNull ( level , "Level must not be null" ) ;
Assert . notNull ( level , "Level must not be null" ) ;
String name = ( StringUtils . hasText ( loggerName ) ? loggerName : "" ) ;
if ( loggerName = = null | | ROOT_LOGGER_NAME . equals ( loggerName ) ) {
Logger logger = Logger . getLogger ( name ) ;
loggerName = "" ;
}
Logger logger = Logger . getLogger ( loggerName ) ;
if ( logger ! = null ) {
if ( logger ! = null ) {
logger . setLevel ( LEVELS . convertSystemToNative ( level ) ) ;
logger . setLevel ( LEVELS . convertSystemToNative ( level ) ) ;
}
}
@ -136,7 +134,7 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
while ( names . hasMoreElements ( ) ) {
while ( names . hasMoreElements ( ) ) {
result . add ( getLoggerConfiguration ( names . nextElement ( ) ) ) ;
result . add ( getLoggerConfiguration ( names . nextElement ( ) ) ) ;
}
}
Collections . sort ( result , CO MPARATOR) ;
Collections . sort ( result , CO NFIGURATION_CO MPARATOR) ;
return Collections . unmodifiableList ( result ) ;
return Collections . unmodifiableList ( result ) ;
}
}
@ -148,7 +146,9 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
}
}
LogLevel level = LEVELS . convertNativeToSystem ( logger . getLevel ( ) ) ;
LogLevel level = LEVELS . convertNativeToSystem ( logger . getLevel ( ) ) ;
LogLevel effectiveLevel = LEVELS . convertNativeToSystem ( getEffectiveLevel ( logger ) ) ;
LogLevel effectiveLevel = LEVELS . convertNativeToSystem ( getEffectiveLevel ( logger ) ) ;
return new LoggerConfiguration ( logger . getName ( ) , level , effectiveLevel ) ;
String name = ( StringUtils . hasLength ( logger . getName ( ) ) ? logger . getName ( )
: ROOT_LOGGER_NAME ) ;
return new LoggerConfiguration ( name , level , effectiveLevel ) ;
}
}
private Level getEffectiveLevel ( Logger root ) {
private Level getEffectiveLevel ( Logger root ) {