-
Notifications
You must be signed in to change notification settings - Fork 13.2k
[ISSUE #13940]: Eliminate ClassUnload during config reload using Configuration.initialize() #14000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
|
It's looks great. But there is the question: Do you test the version ranges of this changes? Before merged I want you to test the version ranges of log4j2. |
Yes, I have tested the version ranges of Log4j2. I ran the adapter module tests (log4j2-adapter) against multiple Log4j2 versions by overriding the log4j.version Maven property: All tests passed successfully across the following versions: Log4j2 2.7: ✅ 8/8 passed (Minimum supported version) I verified this by checking the method signature across all versions using javap, and all versions (2.7, 2.11.1, 2.14.1, 2.17.2, 2.24.3) have the public void initialize(); method. All other APIs used (Configuration.getAppenders(), addAppender(), addLogger(), LoggerContext.updateLoggers()) are part of the Log4j2 core interface since 2.0+. Conclusion: This change is backward compatible with all supported Log4j2 versions (2.7+) and introduces no breaking changes. |
|
|
Great |
|
@JGoP-L Welcome submit similar PR to v2.x-develop also. BTW, would you mind provider your dingtalk number? We would like invite you into nacos contributor group. |
Sure, no problem. My DingTalk ID is m8s_6u8vg21n1. And I'd be glad to submit similar PRs to the v2.x-develop branch. |
[ISSUE #13940] Fix ClassUnload issue by replacing Configuration.start() with initialize()
What is the purpose of the change
Fix Issue #13940: Resolve the ClassUnload problem during Log4j2 configuration reload.
Root Cause: When Nacos reloads the Log4j2 logging configuration, calling
Configuration.start()triggersPluginManager.loadPlugins(), which causes 150-200 ClassUnload events per reload. This results in significant GC pressure and performance degradation.Solution: Replace
Configuration.start()withConfiguration.initialize()to avoid triggering the plugin manager's plugin discovery and loading process. Theinitialize()method only initializes the configuration without loading plugins, which is more appropriate for merging configurations additively.Key Benefits:
Brief changelog
New Files
Configuration.initialize()instead ofstart()to avoid plugin reloadingModified Files
Log4J2NacosLoggingAdapter.java
configuration.start()withconfigurator.configure(loggerContext, configUri)Log4j2NacosLoggingPropertiesHolder.java
getProperties()getter method to support external property queriesLog4J2NacosLoggingAdapterTest.java
Performance Improvements
Verifying this change
Unit Tests
Run the following command to verify all tests pass: