JoaoJandre opened a new pull request, #7131: URL: https://github.com/apache/cloudstack/pull/7131
### Description This PR normalizes ACS's loggers and upgrades log4j 1.2 to log4j 2.19. Back in 2015, PR #714 tried to normalize the loggers but, because that normalization caused some issues with the VMware module, it ended up being reverted. This PR intends to follow that PR's footsteps and normalize all of the loggers in ACS. The objective of reducing unnecessary logger declarations, and reduce the area of impact to upgrade ACS's logger framework from log4j 1.2 to log4 2.19. The log4j upgrade was done similarly to the proposed here https://github.com/apache/cloudstack/pull/2992#issuecomment-439132311, and is more detailed ahead. The logger normalization includes: - Classes that could have their loggers inherited from their ancestors had their own loggers deleted; - Most loggers didn't have to be static, thus most of them were normalized so that they wouldn't be; - loggers are protected now; - Static logger's names are now 'LOGGER'; - Non-static logger's names are now 'logger'; - New class DbUpgradeAbstractImpl created so that all Upgraders extend it and inherit its logger; - The following classes now have loggers (so that all their children can inherit their loggers): `BaseElement`, `PipelineImpl`, `AbstractRect`, `AbstractSmartLifeCycle`, `ManagedContextRunnable`, `Command`, `RuleApplier`, `VmWork`, `ModelObjectBase`, `SnapshotStrategyBase`, `VifDriver`. To normalize all the loggers in ACS, the following steps were performed: 1. The DbUpgradeAbstractImpl class was created; 2. This script https://pastebin.pl/view/6ff71b26 was used to make all the Upgraders extend the DbUpgradeAbstractImpl class (I manually had to correct some of them afterward); 3. I ran this script https://pastebin.pl/view/89931790 for all ACS java classes; the, I checked if classes can inherit the logger from their ancestor*; if they can, then remove their current logger instantiation. If they cannot then leave the instantiation, but make it non-static. And in some cases, rename the logger references to `logger`; 4. I tried to build ACS many times and manually fixed the errors, most of them were because some loggers did indeed have to be static. *The ancestor list I created came from a previous iteration of this process, where I tried to simply remove logger instantiation from any class that extended any other class, the list was created while manually fixing the errors. For the log4j upgrade, the following steps were performed: 1. The relevant pom.xml files were updated; 2. This script https://pastebin.pl/view/0b6b77f9 was used to update all the logger imports; 3. I tried to build ACS many times and manually fixed the errors. About the log4j upgrade: - The DOMConfigurator does not exist in log4j2, its functionality was moved to the Configurator class; - Both NDC and MDC were merged into the ThreadContext class; Disclaimers: - The new log4j2 configuration file format is not backwards compatible with the old one, users must update their configuration files to match with the new format. I used the official apache documentation to upgrade the default configurations, available [here](https://logging.apache.org/log4j/2.x/manual/migration.html#Log4j2ConfigurationFormat). - If you call EncryptorCLI manually, you must also pass the log4j2 jar path (which should be in the same directory as cloud-utils). The are still some points to address/discuss in order to make this PR ready: - ~~Refactor the following classes so that they can be used in log4j2:`SnmpTrapAppender`, `AlertsSyslogAppender`, `TestAppender`, `SnmpEnhancedPatternLayout`~~; - ~~Convert CglibThrowableRenderer functionality to log4j2;~~ - The log4j 1.2 dependency could not be completely removed because juniper contrail has log4j as a dependency. - ~~Test logging for management, agent, usage, SSVMs and CPVMs~~ ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Bug fix (non-breaking change which fixes an issue) - [X] Enhancement (improves an existing feature and functionality) - [X] Cleanup (Code refactoring and cleanup, that may add test cases) ### Feature/Enhancement Scale or Bug Severity #### Feature/Enhancement Scale - [X] Major - [ ] Minor #### Bug Severity - [ ] BLOCKER - [ ] Critical - [ ] Major - [ ] Minor - [ ] Trivial ### Screenshots (if appropriate): ### How Has This Been Tested? I tested if both the console and the file appenders were logging correctly in the management server, agents, and system VMs. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
