Skip to content

Fix deprecated Log4j2 package scanning warnings#13902

Merged
KomachiSion merged 3 commits intoalibaba:developfrom
fyeeme:feat/log4j2-deprecated
Nov 5, 2025
Merged

Fix deprecated Log4j2 package scanning warnings#13902
KomachiSion merged 3 commits intoalibaba:developfrom
fyeeme:feat/log4j2-deprecated

Conversation

@fyeeme
Copy link
Contributor

@fyeeme fyeeme commented Oct 27, 2025

What is the purpose of the change

Fix #12102 deprecated Log4j2 package scanning warnings

Brief changelog

According to Log4j 2.19.1 updates, package scanning functionality has been deprecated (LOG4J2-3644), requiring removal of:

  • PluginManager.addPackage() method calls
  • packages attribute in configuration files

Key changes:

  1. Removed deprecated PluginManager.addPackage() call from Log4J2NacosLoggingAdapter.java
  2. Removed packages attribute from nacos-log4j2.xml configuration file
  3. Configured Maven compiler plugin to use Log4j annotation processor for automatic plugin descriptor generation

The new implementation uses Log4j annotation processor to automatically discover @plugin annotated classes during compilation,
generating Log4j2Plugins.dat file for modern plugin discovery mechanism.

This maintains full functionality of NacosClientPropertiesLookup plugin
while eliminating all deprecated method warnings.

Resolves warning:
WARN The use of package scanning to locate Log4j plugins is deprecated.

log4j Registering plugins

@github-actions
Copy link

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

@CLAassistant
Copy link

CLAassistant commented Oct 27, 2025

CLA assistant check
All committers have signed the CLA.

@fyeeme
Copy link
Contributor Author

fyeeme commented Oct 27, 2025

This branch was created from version 2.4.3 (the default Nacos version in SCA 2023.0.3.4). After merging, should a new patch version be released?

@fyeeme
Copy link
Contributor Author

fyeeme commented Oct 28, 2025

anyone else ?

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 3, 2025

ok, this is bacause my idea set default format style, I'll use text editor to change this file

@fyeeme fyeeme force-pushed the feat/log4j2-deprecated branch from ec4534c to 955b21c Compare November 3, 2025 08:34
@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 3, 2025

@KomachiSion code style have been resolved

<properties>
<maven.compiler.source>${client.java.version}</maven.compiler.source>
<maven.compiler.target>${client.java.version}</maven.compiler.target>
<log4j2.version>2.23.1</log4j2.version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有个问题,父pom里已经有指定log4j2的版本了

    <log4j.version>2.24.3</log4j.version>

如果这里重新定义一个版本,会不会导致一些兼容性问题。

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 3, 2025

@KomachiSion 本地编译过了,已经可以了,项目不熟悉,没看到 项目父 pom.xml已经定义了,麻烦在 rReview 一下

@KomachiSion
Copy link
Collaborator

@fyeeme

之前的PR似乎引入了PMD的失败校验, 会在develop分支先修复, 麻烦待修复之后重新同步一下develop分支。 抱歉了。

修复之后会在PR中再at你

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 4, 2025

好的

@KomachiSion
Copy link
Collaborator

@fyeeme 麻烦在同步一下develop分支

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 4, 2025

已经合并了 @KomachiSion

@fyeeme fyeeme requested a review from KomachiSion November 4, 2025 14:00
@KomachiSion KomachiSion added area/Client Related to Nacos Client SDK kind/enhancement Category issues or prs related to enhancement. labels Nov 5, 2025
@KomachiSion KomachiSion added this to the 3.1.1 milestone Nov 5, 2025
@KomachiSion KomachiSion merged commit 7d9871c into alibaba:develop Nov 5, 2025
3 checks passed
@KomachiSion
Copy link
Collaborator

@fyeeme Welcome submit this change to v2.x-develop with a new PR.

@wuyfee
Copy link

wuyfee commented Nov 5, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

@fyeeme
Copy link
Contributor Author

fyeeme commented Nov 5, 2025

好的,我晚一点在提交一个PR

fyeeme added a commit to fyeeme/nacos that referenced this pull request Nov 5, 2025
* fix: deprecated Log4j2 package scanning warnings

* fix: replace log4j2.version property with log4j.version in log4j2-adapter
KomachiSion pushed a commit that referenced this pull request Nov 6, 2025
* Fix deprecated Log4j2 package scanning warnings (#13902)

* fix: deprecated Log4j2 package scanning warnings

* fix: replace log4j2.version property with log4j.version in log4j2-adapter

* revert: log4j2 config

* feat: add root level config for log4j
@fyeeme fyeeme deleted the feat/log4j2-deprecated branch November 7, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/Client Related to Nacos Client SDK kind/enhancement Category issues or prs related to enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log4j2 升级到 2.23.1版本后,Nacos 会导致 Log4j2 日志输出异常

4 participants