Skip to content

Upgrade to Logback 1.5.7 #41885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -17,6 +17,7 @@
package org.springframework.boot.logging.logback;

import java.nio.charset.Charset;
import java.util.concurrent.locks.ReentrantLock;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
Expand Down Expand Up @@ -44,6 +45,7 @@
* @author Robert Thornton
* @author Scott Frederick
* @author Jonatan Ivanov
* @author Mark Chesney
*/
class DefaultLogbackConfiguration {

Expand All @@ -54,7 +56,9 @@ class DefaultLogbackConfiguration {
}

void apply(LogbackConfigurator config) {
synchronized (config.getConfigurationLock()) {
ReentrantLock lock = config.getConfigurationLock();
lock.lock();
try {
defaults(config);
Appender<ILoggingEvent> consoleAppender = consoleAppender(config);
if (this.logFile != null) {
Expand All @@ -65,6 +69,9 @@ void apply(LogbackConfigurator config) {
config.root(Level.INFO, consoleAppender);
}
}
finally {
lock.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 All @@ -35,6 +36,7 @@
* Allows programmatic configuration of logback which is usually faster than parsing XML.
*
* @author Phillip Webb
* @author Mark Chesney
*/
class LogbackConfigurator {

Expand All @@ -49,7 +51,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 @@ -36,6 +36,7 @@
* control over how and when the logging system is initialized.
*
* @author Andy Wilkinson
* @author Mark Chesney
*/
class LogbackLoggingSystemParallelInitializationTests {

Expand All @@ -45,6 +46,7 @@ class LogbackLoggingSystemParallelInitializationTests {
void cleanUp() {
this.loggingSystem.cleanUp();
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.ILoggerFactory;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
Expand Down Expand Up @@ -93,8 +94,9 @@
* @author Scott Frederick
* @author Jonatan Ivanov
* @author Moritz Halbritter
* @author Mark Chesney
*/
@ExtendWith(OutputCaptureExtension.class)
@ExtendWith({ MockitoExtension.class, OutputCaptureExtension.class })
@ClassPathExclusions({ "log4j-core-*.jar", "log4j-api-*.jar" })
class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {

Expand Down Expand Up @@ -128,6 +130,7 @@ void cleanUp() {
System.getProperties().keySet().retainAll(this.systemPropertyNames);
this.loggingSystem.cleanUp();
((LoggerContext) LoggerFactory.getILoggerFactory()).stop();
((LoggerContext) LoggerFactory.getILoggerFactory()).reset();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @author Phillip Webb
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Mark Chesney
*/
@ExtendWith(OutputCaptureExtension.class)
class SpringBootJoranConfiguratorTests {
Expand Down Expand Up @@ -72,6 +73,7 @@ void setup(CapturedOutput output) {
@AfterEach
void reset() {
this.context.stop();
this.context.reset();
new BasicConfigurator().configure((LoggerContext) LoggerFactory.getILoggerFactory());
}

Expand Down