Skip to content

Commit

Permalink
Upgrade to Logback 1.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Aug 16, 2024
1 parent cca5516 commit e35bc3e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ bom {
releaseNotes("https://github.com/apache/logging-log4j2/releases/tag/rel%2F{version}")
}
}
library("Logback", "1.5.6") {
library("Logback", "1.5.7") {
group("ch.qos.logback") {
modules = [
"logback-classic",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class DefaultLogbackConfiguration {
}

void apply(LogbackConfigurator config) {
synchronized (config.getConfigurationLock()) {
config.getConfigurationLock().lock();
try {
defaults(config);
Appender<ILoggingEvent> consoleAppender = consoleAppender(config);
if (this.logFile != null) {
Expand All @@ -65,6 +66,9 @@ void apply(LogbackConfigurator config) {
config.root(Level.INFO, consoleAppender);
}
}
finally {
config.getConfigurationLock().unlock();
}
}

private void defaults(LogbackConfigurator config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
Expand Down Expand Up @@ -49,7 +50,7 @@ LoggerContext getContext() {
return this.context;
}

Object getConfigurationLock() {
ReentrantLock getConfigurationLock() {
return this.context.getConfigurationLock();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ protected void loadDefaults(LoggingInitializationContext initializationContext,
: new LogbackConfigurator(context);
new DefaultLogbackConfiguration(logFile).apply(configurator);
context.setPackagingDataEnabled(true);
context.start();
});
}

Expand All @@ -256,6 +257,7 @@ protected void loadConfiguration(LoggingInitializationContext initializationCont
catch (Exception ex) {
throw new IllegalStateException("Could not initialize Logback logging from " + location, ex);
}
loggerContext.start();
});
reportConfigurationErrorsIfNecessary(loggerContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void setup(CapturedOutput output) {
void reset() {
this.context.stop();
new BasicConfigurator().configure((LoggerContext) LoggerFactory.getILoggerFactory());
this.context.start();
}

@Test
Expand Down

0 comments on commit e35bc3e

Please sign in to comment.