Should I use constants for log messages?

Just a quick question about the form.

I am logging various error messages and wondering if I should create a new line for the message in the log call or create a constant line in the interface that I use to store other string constants, and then just refer to this. I used the code analyzer code, and it referenced the latter, saying that it is better to create a string constant and refer to it, even if it is used only once. I'm just wondering if this is true?

Thanks in advance

+5
source share
2 answers

, , . Java ( String, ), ?

, , , : Java , ( - !)

: .

+3

; . MessageFormats, / .

, , .

, .

.

+2

All Articles