{"record":{"id":"cf868b8b2abef1fb","repo":"apache/druid","slug":"not-registering-log4j-shutdown-hooks-not-using-lo","errorCode":null,"errorMessage":"Not registering log4j shutdown hooks. Not using log4j?","messagePattern":"Not registering log4j shutdown hooks\\. Not using log4j\\?","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java","lineNumber":82,"sourceCode":"        );\n        return;\n      }\n      final ShutdownCallbackRegistry registry = ((Log4jContextFactory) contextFactory).getShutdownCallbackRegistry();\n      if (!(registry instanceof Log4jShutdown)) {\n        log.warn(\n            \"Shutdown callback registry expected class [%s] found [%s]. Skipping shutdown registry\",\n            Log4jShutdown.class.getName(),\n            registry.getClass().getName()\n        );\n        return;\n      }\n      binder.bind(Log4jShutdown.class).toInstance((Log4jShutdown) registry);\n      binder.bind(Key.get(Log4jShutterDowner.class, Names.named(\"ForTheEagerness\")))\n            .to(Log4jShutterDowner.class)\n            .asEagerSingleton();\n    }\n    catch (ClassNotFoundException | ClassCastException | LinkageError e) {\n      log.warn(e, \"Not registering log4j shutdown hooks. Not using log4j?\");\n    }\n  }\n\n\n  @ManageLifecycleInit\n  @Provides\n  public Log4jShutterDowner getShutterDowner(\n      Log4jShutdown log4jShutdown\n  )\n  {\n    return new Log4jShutterDowner(log4jShutdown);\n  }\n\n  public static class Log4jShutterDowner\n  {\n    private final Log4jShutdown log4jShutdown;\n\n    public Log4jShutterDowner(Log4jShutdown log4jShutdown)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/initialization/Log4jShutterDownerModule.java#L64-L100","documentation":"This warning is the fallback catch in configure(): when log4j API/core classes are absent (ClassNotFoundException), cast to expected log4j types fails (ClassCastException), or linkage fails, the module gives up on registering shutdown hooks. It indicates the process is not running log4j2 as its logging implementation, so Druid cannot perform a managed log4j shutdown.","triggerScenarios":"Startup in an environment where org.apache.logging.log4j.LogManager or ShutdownCallbackRegistry cannot be loaded, or the registry/factory casts fail — typically when log4j-core is not on the runtime classpath or an alternate SLF4J provider is bound.","commonSituations":"Running Druid in a slimmed container without log4j-core, deploying only the API jar, dependency conflicts from extensions pulling in different logging stacks.","solutions":["Add org.apache.logging.log4j:log4j-core (matching the log4j-api version) to the runtime classpath","Verify with `mvn dependency:tree` that only one SLF4J provider is present and it is log4j-slf4j-impl","If alternate logging is intentional, treat this as informational and configure shutdown behavior for that provider instead"],"exampleFix":"// before (classpath)\nlog4j-api-2.x.jar  (no core)\n// after\nlog4j-api-2.x.jar\nlog4j-core-2.x.jar\nlog4j-slf4j-impl-2.x.jar","handlingStrategy":"validation","validationCode":"boolean hasLog4j() { try { Class.forName(\"org.apache.logging.log4j.core.util.ShutdownCallbackRegistry\"); return true; } catch (ClassNotFoundException | LinkageError e) { return false; } }","typeGuard":"boolean isLog4jAvailable() { try { Class.forName(\"org.apache.logging.log4j.LogManager\"); return true; } catch (Throwable t) { return false; } }","tryCatchPattern":null,"preventionTips":["Include log4j-core in the runtime image; don't ship only log4j-api","Run `mvn dependency:tree` after adding extensions to catch logging conflicts","Treat this warning at startup as a configuration bug, not noise"],"tags":["logging","log4j","classpath","startup"],"backgroundTag":"missing-optional-dependency","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}