This discussion is archived
1 Reply Latest reply: Aug 12, 2009 3:13 PM by 843829 RSS

Optimizing out logging statements that have no effect

843829 Newbie
Currently Being Moderated
Hi, it seems a common problem is that when doing logging such as:
logger.debug("got message: " + message);
we pay for the cost of constructing a new String, which is an operation with no side effects - unless we first check that the logging level is at least DEBUG, which is tedious, more verbose, and easily omitted. Does Hotspot have any optimization tricks for avoiding this cost in logging statements like the one above? Thanks in advance for any answers.