|
|
@ -30,6 +30,7 @@ import ch.qos.logback.classic.Level;
|
|
|
|
import ch.qos.logback.classic.LoggerContext;
|
|
|
|
import ch.qos.logback.classic.LoggerContext;
|
|
|
|
import ch.qos.logback.classic.joran.JoranConfigurator;
|
|
|
|
import ch.qos.logback.classic.joran.JoranConfigurator;
|
|
|
|
import ch.qos.logback.classic.jul.LevelChangePropagator;
|
|
|
|
import ch.qos.logback.classic.jul.LevelChangePropagator;
|
|
|
|
|
|
|
|
import ch.qos.logback.classic.spi.TurboFilterList;
|
|
|
|
import ch.qos.logback.classic.turbo.TurboFilter;
|
|
|
|
import ch.qos.logback.classic.turbo.TurboFilter;
|
|
|
|
import ch.qos.logback.core.joran.spi.JoranException;
|
|
|
|
import ch.qos.logback.core.joran.spi.JoranException;
|
|
|
|
import ch.qos.logback.core.spi.FilterReply;
|
|
|
|
import ch.qos.logback.core.spi.FilterReply;
|
|
|
@ -219,34 +220,38 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
|
|
|
|
protected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile) {
|
|
|
|
protected void loadDefaults(LoggingInitializationContext initializationContext, LogFile logFile) {
|
|
|
|
LoggerContext context = getLoggerContext();
|
|
|
|
LoggerContext context = getLoggerContext();
|
|
|
|
stopAndReset(context);
|
|
|
|
stopAndReset(context);
|
|
|
|
boolean debug = Boolean.getBoolean("logback.debug");
|
|
|
|
withLoggingSuppressed(() -> {
|
|
|
|
if (debug) {
|
|
|
|
boolean debug = Boolean.getBoolean("logback.debug");
|
|
|
|
StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener());
|
|
|
|
if (debug) {
|
|
|
|
}
|
|
|
|
StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener());
|
|
|
|
Environment environment = initializationContext.getEnvironment();
|
|
|
|
}
|
|
|
|
// Apply system properties directly in case the same JVM runs multiple apps
|
|
|
|
Environment environment = initializationContext.getEnvironment();
|
|
|
|
new LogbackLoggingSystemProperties(environment, getDefaultValueResolver(environment), context::putProperty)
|
|
|
|
// Apply system properties directly in case the same JVM runs multiple apps
|
|
|
|
.apply(logFile);
|
|
|
|
new LogbackLoggingSystemProperties(environment, getDefaultValueResolver(environment), context::putProperty)
|
|
|
|
LogbackConfigurator configurator = debug ? new DebugLogbackConfigurator(context)
|
|
|
|
.apply(logFile);
|
|
|
|
: new LogbackConfigurator(context);
|
|
|
|
LogbackConfigurator configurator = debug ? new DebugLogbackConfigurator(context)
|
|
|
|
new DefaultLogbackConfiguration(logFile).apply(configurator);
|
|
|
|
: new LogbackConfigurator(context);
|
|
|
|
context.setPackagingDataEnabled(true);
|
|
|
|
new DefaultLogbackConfiguration(logFile).apply(configurator);
|
|
|
|
|
|
|
|
context.setPackagingDataEnabled(true);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void loadConfiguration(LoggingInitializationContext initializationContext, String location,
|
|
|
|
protected void loadConfiguration(LoggingInitializationContext initializationContext, String location,
|
|
|
|
LogFile logFile) {
|
|
|
|
LogFile logFile) {
|
|
|
|
if (initializationContext != null) {
|
|
|
|
|
|
|
|
applySystemProperties(initializationContext.getEnvironment(), logFile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LoggerContext loggerContext = getLoggerContext();
|
|
|
|
LoggerContext loggerContext = getLoggerContext();
|
|
|
|
stopAndReset(loggerContext);
|
|
|
|
stopAndReset(loggerContext);
|
|
|
|
try {
|
|
|
|
withLoggingSuppressed(() -> {
|
|
|
|
configureByResourceUrl(initializationContext, loggerContext, ResourceUtils.getURL(location));
|
|
|
|
if (initializationContext != null) {
|
|
|
|
}
|
|
|
|
applySystemProperties(initializationContext.getEnvironment(), logFile);
|
|
|
|
catch (Exception ex) {
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Could not initialize Logback logging from " + location, ex);
|
|
|
|
try {
|
|
|
|
}
|
|
|
|
configureByResourceUrl(initializationContext, loggerContext, ResourceUtils.getURL(location));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
throw new IllegalStateException("Could not initialize Logback logging from " + location, ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
reportConfigurationErrorsIfNecessary(loggerContext);
|
|
|
|
reportConfigurationErrorsIfNecessary(loggerContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -455,6 +460,17 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
|
|
|
|
return contribution;
|
|
|
|
return contribution;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void withLoggingSuppressed(Runnable action) {
|
|
|
|
|
|
|
|
TurboFilterList turboFilters = getLoggerContext().getTurboFilterList();
|
|
|
|
|
|
|
|
turboFilters.add(FILTER);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
action.run();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
finally {
|
|
|
|
|
|
|
|
turboFilters.remove(FILTER);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@link LoggingSystemFactory} that returns {@link LogbackLoggingSystem} if possible.
|
|
|
|
* {@link LoggingSystemFactory} that returns {@link LogbackLoggingSystem} if possible.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|