java - Logging debug messages -


out of curiosity, there benefit when logging (using log4j) use above approach:

if (logger.isdebugenabled()) {      logger.debug("new session created"); } 

rather just:

 logger.debug("new session created"); 

is merely (potential) performance enhancement , still relevant? should used wrap debug output?

thanks thoughts!

in use case, no, there's no benefit whatsoever.

however, if constructing new string, example, "new session create" + sessionid, you'd want avoid string construction , rather use boolean check.

it's small difference, in large application, string construction, , associated garbage collection, become point of performance impact. if pass static strings, however, creating duplicate check, which, while small, has possible performance impact.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -