alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.29k stars 12.84k forks source link

nacos-client 1.4.6 版本与 Log4j 2.18.0 版本集成,启动时会有log配置错误日志输出 #11397

Closed MVP2142 closed 11 months ago

MVP2142 commented 12 months ago

Describe the bug nacos-client 1.4.6 版本与 Log4j 2.18.0 版本集成,启动时会有ERROR级别的log.xml配置错误日志输出,输出内容为:

2023-11-16 11:11:11 main ERROR Unknown object "Async" of type org.apache.logging.log4j.core.appender.AsyncAppender is ignorder: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"] 2023-11-16 11:11:11 main ERROR Unable to locate appender "ASYNC_NAMING" for logger config "com.alibaba.nacos.client.naming"

日志打印源码为:log4j-core 2.18.0包中,org.apache.logging.log4j.core.config.AbstractConfiguration#doConfigure方法696行

读取的是nacos-client包中的nacos-log4j2.xml配置文件,文件中存在< Async >标签

Desktop (please complete the following information):

KomachiSion commented 11 months ago

新版本log4j2不支持异步日志了吗? 如果支持的话需要如何配置?

MVP2142 commented 11 months ago

新版本log4j2不支持异步日志了吗? 如果支持的话需要如何配置?

重新看了下配置文件,是1.4.6的配置文件Async标签配错地方了,改一下就可以了,Async需要配置在Appenders标签中 image

53行的ASYNC_NAMING配置在Appenders外所以报错了,34行的ASYNC_CONFIG就没有报错。 @KomachiSion

KomachiSion commented 11 months ago

那修改后是否不再兼容旧版本?

MVP2142 commented 11 months ago

和log4j版本应该没关系,就是nacos-client里面自己配错了,34-36行的< Async >已经写在< Appenders >里面了。 53-55的却写在了< Appenders > 外面,应该是当时的开发人员没注意写错位置了吧 @KomachiSion

KomachiSion commented 11 months ago

那欢迎PR修复一下

MVP2142 commented 11 months ago

该问题在v1.x-develop分支的 2023/9/28 的提交【feat: 新增滚动删除策略,解决日志文件数量无限制的隐患 (#11189) (commit id: bf17472c)】中已经修复,接下来只需要等待v1.x-develop合并回v1.x分支并重新发布到中央仓库就行了吧?

image
KomachiSion commented 11 months ago

对的