diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 1148a9e7b9..a0b6211afe 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -17,6 +17,8 @@ package org.springframework.boot.logging.logback; import java.net.URL; +import java.security.CodeSource; +import java.security.ProtectionDomain; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -146,10 +148,21 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { + "implementation (%s loaded from %s). If you are using " + "Weblogic you will need to add 'org.slf4j' to " + "prefer-application-packages in WEB-INF/weblogic.xml", - factory.getClass(), factory.getClass().getProtectionDomain() - .getCodeSource().getLocation())); - + factory.getClass(), getLocation(factory))); return (LoggerContext) factory; } + private Object getLocation(ILoggerFactory factory) { + try { + ProtectionDomain protectionDomain = factory.getClass().getProtectionDomain(); + CodeSource codeSource = protectionDomain.getCodeSource(); + if (codeSource != null) { + return codeSource.getLocation(); + } + } + catch (SecurityException ex) { + // Unable to determine location + } + return "unknown location"; + } }