-1

Possible Duplicate:
Is there a need to do a if(log.isDebugEnabled()) { … } check?

My question is why do we need to check log.isDebugEnabled condition before writing into logs. In production environment i will not give Debug mode at all. So only errors will be logged. In such cases , i feel this extra condition is a burden. Can anyone please explain me the logic behind writing.

Community
  • 1
  • 1
freepublicview
  • 716
  • 2
  • 12
  • 25

1 Answers1

1

Adding this line gives the runtime a chance to eliminate the line from the code entirely. If the log level is set to anything other than debug, the runtime can remove all those calls as an optimization. If it knows that a condition is always true there's no need for the block at all.

duffymo
  • 305,152
  • 44
  • 369
  • 561