Commit 1ca73a9f authored by Phillip Webb's avatar Phillip Webb

Improve exception message for Weblogic

Ensure that a sensible exception message is thrown if the user happens
to include the logback jar in their deployment.

Fixes gh-2077
parent c8b9da04
...@@ -130,26 +130,25 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { ...@@ -130,26 +130,25 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
getLogger(loggerName).setLevel(LEVELS.get(level)); getLogger(loggerName).setLevel(LEVELS.get(level));
} }
private ch.qos.logback.classic.Logger getLogger(String name) {
LoggerContext factory = getLoggerContext();
return factory.getLogger(StringUtils.isEmpty(name) ? Logger.ROOT_LOGGER_NAME
: name);
}
private LoggerContext getLoggerContext() { private LoggerContext getLoggerContext() {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory(); ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
Assert.isInstanceOf( Assert.isInstanceOf(LoggerContext.class, factory, String.format(
LoggerContext.class,
factory,
String.format(
"LoggerFactory is not a Logback LoggerContext but Logback is on " "LoggerFactory is not a Logback LoggerContext but Logback is on "
+ "the classpath. Either remove Logback or the competing " + "the classpath. Either remove Logback or the competing "
+ "implementation (%s loaded from %s).", + "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() factory.getClass(), factory.getClass().getProtectionDomain()
.getCodeSource().getLocation())); .getCodeSource().getLocation()));
return (LoggerContext) factory; return (LoggerContext) factory;
} }
private ch.qos.logback.classic.Logger getLogger(String name) {
ILoggerFactory factory = StaticLoggerBinder.getSingleton().getLoggerFactory();
return (ch.qos.logback.classic.Logger) factory.getLogger(StringUtils
.isEmpty(name) ? Logger.ROOT_LOGGER_NAME : name);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment