Skip to content

Replace LogManager.getLogger() with @Slf4j #2021

@AshishBagdane

Description

@AshishBagdane

Description

Currently, our codebase uses private final Logger logger = LogManager.getLogger(); for logging. We need to replace it with Lombok’s @Slf4j annotation to reduce boilerplate code and improve maintainability.

Why?

  1. Flexibility@Slf4j is a logging abstraction that allows switching between different logging frameworks (e.g., Log4j2, Logback) without modifying the code.
  2. Future-Proofing – Unlike @Log4j, which tightly couples our code to Log4j, @Slf4j ensures we can easily switch to another backend if needed.
  3. Less Boilerplate@Slf4j automatically generates the logger instance, removing the need for explicit declarations like LogManager.getLogger().
  4. Best Practices – Many modern Java projects prefer @Slf4j as it integrates well with different logging backends and provides better adaptability.

Action Items:

  • Replace all occurrences of private final Logger logger = LogManager.getLogger(); with @Slf4j annotation.
  • Ensure no functionality is broken after the migration.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions