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

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

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

google shop client API returns 400 bad request error while adding an item -