I’m trying to trace an expression to Log4j.
Assuming the evaluation of this expression is expensive, and does not produce any side-effects, is Java smart enough to prevent the overhead of the expression computation in WARN mode?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. This exactly why you have lot of
if(logger.isXXXEnabled())checks scattered across code base. I suggest you shift to slf4j which avoids this evaluation (provided you use it properly i.e. parameterized logging).