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
This commit is contained in:
parent
c8b9da0492
commit
1ca73a9f46
|
@ -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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue