alibaba/nacos · error · IllegalStateException
Could not initialize Log4J2 logging from {}
Error message
Could not initialize Log4J2 logging from {} What it means
Error "Could not initialize Log4J2 logging from {}" thrown in alibaba/nacos.
Source
Thrown at logger-adapter-impl/log4j2-adapter/src/main/java/com/alibaba/nacos/logger/adapter/log4j2/Log4J2NacosLoggingAdapter.java:117
return;
}
// Thread-safe double-checked locking to prevent duplicate loading in concurrent scenarios
// Although normal usage is single-threaded (via ScheduledExecutorService), this ensures
// robustness in edge cases like concurrent framework initialization or testing scenarios
synchronized (loggerContext) {
final Configuration config = loggerContext.getConfiguration();
if (config.getAppender(APPENDER_MARK) != null) {
return;
}
try {
// Use custom NacosLog4j2Configurator (framework-compliant approach similar to Logback)
URI configUri = ResourceUtils.getResourceUrl(location).toURI();
configurator.configure(loggerContext, configUri);
} catch (Exception e) {
throw new IllegalStateException(
"Could not initialize Log4J2 logging from " + location, e);
}
}
}
}
View on GitHub (pinned to 9b989acdf1)
Solutions
- Review the input and runtime state for log4j2 init failed, correct the reported problem, and retry.
When it happens
Trigger: 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.
Common situations: Log4J2 logging initialization from the given configuration location failed.
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/f1395670aeb30dbd.
Report an issue: GitHub.