Replace debug messages with static trailing strings
Considered a good replacement for hardcoded values ββwith static final properties in the java.
However, I notice that developers usually hardcode the log message.
Does it make sense to move log messages to static final properties?
public class MyClass {
private static final Logger LOGGER = Logger.getLogger(MyClass.class));
public void foo() {
LOGGER.info("My message");
}
}
VS
public class MyClass {
private static final Logger LOGGER = Logger.getLogger(MyClass.class);
private static final String MY_MESSAGE = "My message";
public void foo() {
LOGGER.info(MY_MESSAGE);
}
}
+3
source to share