Performance: Logger creation in classes
MEDIUM IMPACT
This affects application startup time and memory usage due to logger instance creation in each class.
public class MyService { private static final Logger logger = LoggerFactory.getLogger(MyService.class); // reuse logger efficiently } // or use centralized logging configuration
public class MyService { private Logger logger = LoggerFactory.getLogger(MyService.class); // class code } // repeated in every class
| Pattern | Memory Usage | Startup Impact | Reuse Efficiency | Verdict |
|---|---|---|---|---|
| Static final logger per class | Low (one instance per class) | Minimal | High (reused efficiently) | [OK] Good |
| Dynamic logger creation per method call | High (many instances) | Noticeable delay | Low (new instances each time) | [X] Bad |