{"record":{"id":"f1395670aeb30dbd","repo":"alibaba/nacos","slug":"could-not-initialize-log4j2-logging-from","errorCode":null,"errorMessage":"Could not initialize Log4J2 logging from {}","messagePattern":"Could not initialize Log4J2 logging from (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"logger-adapter-impl/log4j2-adapter/src/main/java/com/alibaba/nacos/logger/adapter/log4j2/Log4J2NacosLoggingAdapter.java","lineNumber":117,"sourceCode":"            return;\n        }\n        \n        // Thread-safe double-checked locking to prevent duplicate loading in concurrent scenarios\n        // Although normal usage is single-threaded (via ScheduledExecutorService), this ensures\n        // robustness in edge cases like concurrent framework initialization or testing scenarios\n        synchronized (loggerContext) {\n            final Configuration config = loggerContext.getConfiguration();\n            if (config.getAppender(APPENDER_MARK) != null) {\n                return;\n            }\n            \n            try {\n                // Use custom NacosLog4j2Configurator (framework-compliant approach similar to Logback)\n                URI configUri = ResourceUtils.getResourceUrl(location).toURI();\n                configurator.configure(loggerContext, configUri);\n                \n            } catch (Exception e) {\n                throw new IllegalStateException(\n                    \"Could not initialize Log4J2 logging from \" + location, e);\n            }\n        }\n    }\n}\n","sourceCodeStart":99,"sourceCodeEnd":123,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/logger-adapter-impl/log4j2-adapter/src/main/java/com/alibaba/nacos/logger/adapter/log4j2/Log4J2NacosLoggingAdapter.java#L99-L123","documentation":"Error \"Could not initialize Log4J2 logging from {}\" thrown in alibaba/nacos.","triggerScenarios":"Thrown at logger-adapter-impl/log4j2-adapter/src/main/java/com/alibaba/nacos/logger/adapter/log4j2/Log4J2NacosLoggingAdapter.java:117 when the library encounters an invalid state.","commonSituations":"Log4J2 logging initialization from the given configuration location failed.","solutions":["Review the input and runtime state for log4j2 init failed, correct the reported problem, and retry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}