-
-
Notifications
You must be signed in to change notification settings - Fork 62
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 LogManager.getLogger() with @Slf4j #2036
base: main
Are you sure you want to change the base?
Conversation
@ideal3147 When I run this branch on
Is this expected behavior? Are you seeing any log output when you run the webapp on your computer? Note that the Log4j configuration relied on a config file at https://github.com/elimu-ai/webapp/blob/main/src/main/resources/log4j2.xml And the production servers used a different config file: https://github.com/elimu-ai/webapp/blob/main/src/main/resources/log4j2_PROD.xml This is so that we could store a daily log file on each server, e.g:
With the new SLF4J setup, how can we store log output in a different file per language? For example:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me. But we also need to figure out how to handle the existing Log4j configurations:
Issue Number
LogManager.getLogger()
with@Slf4j
#2021Purpose
Flexibility – @slf4j is a logging abstraction that allows switching between different logging frameworks (e.g., Log4j2, Logback) without modifying the code.
Future-Proofing – Unlike @log4j, which tightly couples our code to Log4j, @slf4j ensures we can easily switch to another backend if needed.
Less Boilerplate – @slf4j automatically generates the logger instance, removing the need for explicit declarations like LogManager.getLogger().
Best Practices – Many modern Java projects prefer @slf4j as it integrates well with different logging backends and provides better adaptability.
Technical Details