Skip to content

Commit e47435f

Browse files
committed
Include code source location in message for competing LoggerFactory impl
To make it easier to identify the source of the competing LoggerFactory implementation, this commit updates the exception message to include the code source location of the offending class. Closes gh-1630
1 parent f7d1f96 commit e47435f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,16 @@ public void initialize(String configLocation) {
9090
Assert.notNull(configLocation, "ConfigLocation must not be null");
9191
String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(configLocation);
9292
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
93-
Assert.isInstanceOf(LoggerContext.class, factory,
94-
"LoggerFactory is not a Logback LoggerContext but "
95-
+ "Logback is on the classpath. Either remove Logback "
96-
+ "or the competing implementation (" + factory.getClass() + ")");
93+
Assert.isInstanceOf(
94+
LoggerContext.class,
95+
factory,
96+
String.format(
97+
"LoggerFactory is not a Logback LoggerContext but Logback is on "
98+
+ "the classpath. Either remove Logback or the competing "
99+
+ "implementation (%s loaded from %s).",
100+
factory.getClass(), factory.getClass().getProtectionDomain()
101+
.getCodeSource().getLocation()));
102+
97103
LoggerContext context = (LoggerContext) factory;
98104
context.stop();
99105
context.reset();

0 commit comments

Comments
 (0)