mirror of https://github.com/apache/druid.git
Merge pull request #2375 from metamx/moreLog4jChecks
Add check for log4j-core in Log4jShutterDownerModule
This commit is contained in:
commit
b90cee5d0d
|
@ -45,8 +45,15 @@ public class Log4jShutterDownerModule implements Module
|
||||||
// This makes the shutdown run pretty darn near last.
|
// This makes the shutdown run pretty darn near last.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||||
|
if(loader == null) {
|
||||||
|
loader = getClass().getClassLoader();
|
||||||
|
}
|
||||||
// Reflection to try and allow non Log4j2 stuff to run. This acts as a gateway to stop errors in the next few lines
|
// Reflection to try and allow non Log4j2 stuff to run. This acts as a gateway to stop errors in the next few lines
|
||||||
final Class<?> logManagerClazz = Class.forName("org.apache.logging.log4j.LogManager");
|
// In log4j api
|
||||||
|
final Class<?> logManagerClazz = Class.forName("org.apache.logging.log4j.LogManager", false, loader);
|
||||||
|
// In log4j core
|
||||||
|
final Class<?> callbackRegistryClazz = Class.forName("org.apache.logging.log4j.core.util.ShutdownCallbackRegistry", false, loader);
|
||||||
|
|
||||||
final LoggerContextFactory contextFactory = LogManager.getFactory();
|
final LoggerContextFactory contextFactory = LogManager.getFactory();
|
||||||
if (!(contextFactory instanceof Log4jContextFactory)) {
|
if (!(contextFactory instanceof Log4jContextFactory)) {
|
||||||
|
|
Loading…
Reference in New Issue