Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Could not initialize Logback Nacos logging from classpath:nacos-logback14.xml
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.loadConfigurationOnStart(LogbackNacosLoggingAdapter.java:120)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.access$000(LogbackNacosLoggingAdapter.java:37)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter$NacosLoggerContextListener.onReset(LogbackNacosLoggingAdapter.java:141)
at ch.qos.logback.classic.LoggerContext.fireOnReset(LoggerContext.java:318)
at ch.qos.logback.classic.LoggerContext.reset(LoggerContext.java:366)
at ch.qos.logback.classic.LoggerContext.stop(LoggerContext.java:343)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.stopAndReset(LogbackLoggingSystem.java:300)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadDefaults(LogbackLoggingSystem.java:226)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:84)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:61)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:193)
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:332)
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:298)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:246)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:223)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
at cn.herodotus.cloud.upms.UpmsApplication.main(UpmsApplication.java:39)
Caused by: java.lang.IllegalStateException: [*][variable] already has an associated action supplier
at ch.qos.logback.core.joran.spi.SimpleRuleStore.addRule(SimpleRuleStore.java:89)
at ch.qos.logback.core.joran.JoranConfiguratorBase.addElementSelectorAndActionAssociations(JoranConfiguratorBase.java:56)
at ch.qos.logback.classic.joran.JoranConfigurator.addElementSelectorAndActionAssociations(JoranConfigurator.java:52)
at com.alibaba.nacos.logger.adapter.logback14.NacosLogbackConfiguratorAdapterV2.addElementSelectorAndActionAssociations(NacosLogbackConfiguratorAdapterV2.java:62)
at ch.qos.logback.core.joran.GenericXMLConfigurator.buildSaxEventInterpreter(GenericXMLConfigurator.java:140)
at ch.qos.logback.core.joran.GenericXMLConfigurator.buildModelFromSaxEventList(GenericXMLConfigurator.java:197)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:172)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:123)
at com.alibaba.nacos.logger.adapter.logback14.NacosLogbackConfiguratorAdapterV2.configure(NacosLogbackConfiguratorAdapterV2.java:79)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.loadConfigurationOnStart(LogbackNacosLoggingAdapter.java:118)
... 30 more
Exception in thread "SpringApplicationShutdownHook" java.lang.IllegalStateException: Could not initialize Logback Nacos logging from classpath:nacos-logback14.xml
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.loadConfigurationOnStart(LogbackNacosLoggingAdapter.java:120)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.access$000(LogbackNacosLoggingAdapter.java:37)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter$NacosLoggerContextListener.onReset(LogbackNacosLoggingAdapter.java:141)
at ch.qos.logback.classic.LoggerContext.fireOnReset(LoggerContext.java:318)
at ch.qos.logback.classic.LoggerContext.reset(LoggerContext.java:366)
at ch.qos.logback.classic.LoggerContext.stop(LoggerContext.java:343)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.lambda$getShutdownHandler$2(LogbackLoggingSystem.java:391)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:116)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException: [*][variable] already has an associated action supplier
at ch.qos.logback.core.joran.spi.SimpleRuleStore.addRule(SimpleRuleStore.java:89)
at ch.qos.logback.core.joran.JoranConfiguratorBase.addElementSelectorAndActionAssociations(JoranConfiguratorBase.java:56)
at ch.qos.logback.classic.joran.JoranConfigurator.addElementSelectorAndActionAssociations(JoranConfigurator.java:52)
at com.alibaba.nacos.logger.adapter.logback14.NacosLogbackConfiguratorAdapterV2.addElementSelectorAndActionAssociations(NacosLogbackConfiguratorAdapterV2.java:62)
at ch.qos.logback.core.joran.GenericXMLConfigurator.buildSaxEventInterpreter(GenericXMLConfigurator.java:140)
at ch.qos.logback.core.joran.GenericXMLConfigurator.buildModelFromSaxEventList(GenericXMLConfigurator.java:197)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:172)
at ch.qos.logback.core.joran.GenericXMLConfigurator.doConfigure(GenericXMLConfigurator.java:123)
at com.alibaba.nacos.logger.adapter.logback14.NacosLogbackConfiguratorAdapterV2.configure(NacosLogbackConfiguratorAdapterV2.java:79)
at com.alibaba.nacos.logger.adapter.logback14.LogbackNacosLoggingAdapter.loadConfigurationOnStart(LogbackNacosLoggingAdapter.java:118)
... 9 more
问题描述
Nacos Client 升级至 2.4.0 以后,已有工程运行出错。
个人的环境是:Spring Boot 3.3.1、Spring Cloud 2023.0.3、Spring Cloud Alibaba 2023.0.1.2。
手动将 Nacos Client 依赖的
logback-adapter
排除才能运行。错误信息如下:
重现代码
重现,见 https://github.com/herodotus-ecosystem/nacos-reproduce
目测,是 Bootstrap 模式会加载日志两次。logback-adapter 包除了日志配置文件 nacos-logback14.xml 外,还有代码会动态往 logback 中加内容,所以启动报错。
相关问题
相关问题见: #12387