SLF4J best practices
MSALApplies best practices to logging with SLF4J.
org. openrewrite. java. logging. slf4j. Slf4jBestPracticesmod run . --recipe= org. openrewrite. java. logging. slf4j. Slf4jBestPracticesInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.
Recipe list
It runs these recipes, in this order.
- Unpack Logger method
new Object[] {...}into varargs - Loggers should be named for their enclosing classes
- SLF4J logging statements should begin with constants
String.format()in logging statements should use SLF4J parameterized loggingMessageFormat.format()in logging statements should use SLF4J parameterized logging- Parameterize SLF4J's logging statements
- Enhances logging of exceptions by including the full stack trace in addition to the exception message
- Catch block log level
- Change logger fields to
private - Match
if (is*Enabled())with logging statements - Optimize log statements
- Strip
toString()from arguments - Remove unnecessary log level guards