Attempted to append to closed appender named xxx

本文介绍了解决因公用服务JAR包导致的Log4j配置冲突问题,具体包括检查和修正Appender名称、Root配置及Logger命名冲突的方法。
异常描述:将一将公用服务打成JAR包放置到其他工程里面,系统启动时Log4j打印出如上Error,引发LOG4J失效。
异常解决:检查JAR包中的LOG4J的配置是否与工程中现有的LOG4J配置冲突,其中有可能冲突的地方是:
1、Appender的名称与现有工程冲突。
<appender name="Appender" class="org.apache.log4j.RollingFileAppender">

2、现有工程中已经有ROOT配置,JAR中也包含了些配置,引发冲突。
<root>
<level value="info"/>
<appender-ref ref="LogToFile"/>
</root>
3、 logger 的name与现有工程冲突。
<logger name="com.xxx.xxx" additivity="false">
删除jar包中日志的root配置,并保持appender、logger节点的命名或路径唯一性就可以正常启用LOG4J了。
springaialibaba项目启动出现大量警告:16:00:24,057 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/config.log" as that given for appender [CONFIG_LOG_FILE] defined earlier. 16:00:24,058 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,058 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 16:00:24,059 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/naming.log" as that given for appender [NAMING_LOG_FILE] defined earlier. 16:00:24,059 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,059 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 16:00:24,060 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/remote.log" as that given for appender [REMOTE_LOG_FILE] defined earlier. 16:00:24,061 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,061 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 2025-05-28T16:00:24.067+08:00 INFO 23488 --- [SpringAI-ALibaba] [ main] com.dai.SpringAiAlibabaApplication : Starting SpringAiAlibabaApplication using Java 23.0.1 with PID 23488 (D:\JavaWeb\SpringAI-Alibaba\target\classes started by Dai52 in D:\JavaWeb\SpringAI-Alibaba) 2025-05-28T16:00:24.067+08:00 INFO 23488 --- [SpringAI-ALibaba] [ main] com.dai.SpringAiAlibabaApplication : No active profile set, falling back to 1 default profile: "default" 2025-05-28T16:00:24.684+08:00 WARN 23488 --- [SpringAI-ALibaba] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.cloud.nacos.NacosConfigAutoConfiguration' of type [com.alibaba.cloud.nacos.NacosConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [nacosAnnotationProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead. 2025-05-28T16:00:24.688+08:00 WARN 23488 --- [SpringAI-ALibaba] [ main] trationDelegate$BeanPostProcessorChecker : Bean 'nacosConfigProperties' of type [com.alibaba.cloud.nacos.NacosConfigProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [nacosAnnotationProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE. 16:00:24,695 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/config.log" as that given for appender [CONFIG_LOG_FILE] defined earlier. 16:00:24,695 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,695 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 16:00:24,696 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/naming.log" as that given for appender [NAMING_LOG_FILE] defined earlier. 16:00:24,696 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,696 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[NAMING_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 16:00:24,697 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - 'File' option has the same value "C:\Users\Dai52/logs/nacos/remote.log" as that given for appender [REMOTE_LOG_FILE] defined earlier. 16:00:24,697 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting. 16:00:24,697 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - For more information, please visit https://logback.qos.ch/codes.html#earlier_fa_collision 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,701 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[CONFIG_LOG_FILE] - Attempted to append to non started appender [CONFIG_LOG_FILE]. 16:00:24,728 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE]. 16:00:24,729 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE]. 16:00:24,729 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE]. 16:00:24,729 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE]. 16:00:24,729 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE]. 16:00:24,729 |-WARN in ch.qos.logback.core.rolling.RollingFileAppender[REMOTE_LOG_FILE] - Attempted to append to non started appender [REMOTE_LOG_FILE].
最新发布
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值