Skip to content
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

Replace Log4j2 with Logback #3425

Closed
wants to merge 1 commit into from
Closed

Replace Log4j2 with Logback #3425

wants to merge 1 commit into from

Conversation

diega
Copy link
Contributor

@diega diega commented Feb 14, 2022

PR description

As a continuation of the work made on #3285 this PR completely removes Log4j2 as a project dependency, substituting its behaviour with Logback. Most importantly, removes custom Log4j2 management for dealing with ANSI colors by using conditionals in the Logback config file.

TODO

  • configure Splunk in logback.xml properly (cc @atoulme)

Documentation changes

Configure logging wiki page will need to be updated. This doc page explains how to override the default location of the configuration file. And also, the Hyperledger Besu Ansible role refers to a besu_log4j_config_file variable.

Changelog

@diega diega force-pushed the logback branch 3 times, most recently from 6ae7367 to b620ebc Compare February 14, 2022 15:07
Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

So far this looks great, thanks so much for migrating this!

One thing we need to think about is how to deprecate inherited CLI flags. I'm not sure the best way to communicate that to users, it could be a breaking change that causes startup scripts to fail.

@diega diega force-pushed the logback branch 3 times, most recently from d32b1c2 to 691baea Compare February 14, 2022 18:22
@diega
Copy link
Contributor Author

diega commented Feb 14, 2022

Thanks @jflo. I tried to respect every existing CLI flag in this PR. Also I followed the exact same output format for logging messages, the only difference is about the colour palette that is used by Log4j2 vs Logback for the different levels.

With regards of the Sonar checks, those were the same approved for #3285, i.e. setting log level explicitly (this time for Logback) and using System.out for when the logging context wasn't initialized yet.

@ajsutton
Copy link
Contributor

Sorry if I've mentioned this before, but how are we dealing with backwards compatibility for people who are using custom log4j.xml configurations?

@atoulme
Copy link
Contributor

atoulme commented Feb 18, 2022

It might still be possible to use log4j2 with slf4j, just need to change the jars in the classpath. There's some options folks can use from there on.
Do you know of anyone using custom log4j2 configs, besides what we use for direct Splunk logging here?

@diega
Copy link
Contributor Author

diega commented Feb 18, 2022

@atoulme I think we are not that agnostic of the logging backend [yet]. Features like changing the log level at runtime are implementation specific and we require implementation level dependency. Another option would be to add an abstraction layer like the one that vert.x has, but I don't know if it wouldn't be too much for Besu

@atoulme
Copy link
Contributor

atoulme commented Feb 19, 2022

I agree, sounds like too much.

@ajsutton
Copy link
Contributor

Do you know of anyone using custom log4j2 configs, besides what we use for direct Splunk logging here?

It's used on all the Besu nodes ConsenSys runs to output logs as JSON which is then sent processed and aggregated etc. I also use it personally particularly for development because it makes it so easy to change logging config at runtime (we do have a JSON-RPC API to do that but it's so much more painful). I've recommended using a custom log4j setup for anyone doing anything serious for years mainly because of that flexibility to change things at runtime - not sure how many people have actually listened...

I don't think it's a big deal to change the custom config format we'd use, but I think we need to give reasonable notice. I'd be against changing the logging backend if there wasn't a roughly equivalent approach to providing custom config, but the logback config looks extremely similar so I don't think we're losing anything, just changing some syntax.

Signed-off-by: Diego López León <dieguitoll@gmail.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 3, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 3 Security Hotspots
Code Smell A 2 Code Smells

74.2% 74.2% Coverage
0.0% 0.0% Duplication

@non-fungible-nelson
Copy link
Contributor

non-fungible-nelson commented May 18, 2022

Hi all - closed for now in favor of the existing solution in #3759. I think we can look at this again when we address tech debt post-merge. There was a larger lift than we could provide at this time.

@diega diega added the mainnet label May 29, 2022
@diega diega deleted the logback branch August 29, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants