> Question: Right now, if debug enabled is serveral lines of code, just > like in the old days. > > Can we place just change the signature of debug and others to indicate > if the loging will only happen if enabled or all the time? > This way I avoid the not nice sytnax of ... if debug enabled.
It already only logs if enabled. See the Performance section of http://logging.apache.org/log4j/docs/manual.html for more info. I have included a portion to explain. The method invocation involves the "hidden" cost of parameter construction. For example, for some logger cat, writing, logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); incurs the cost of constructing the message parameter, i.e. converting both integer i and entry[i] to a String, and concatenating intermediate strings, regardless of whether the message will be logged or not. This cost of parameter construction can be quite high and it depends on the size of the parameters involved. To avoid the parameter construction cost write: if(logger.isDebugEnabled() { logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); } This will not incur the cost of parameter construction if debugging is disabled. On the other hand, if the logger is debug-enabled, it will incur twice the cost of evaluating whether the logger is enabled or not: once in debugEnabled and once in debug. This is an insignificant overhead because evaluating a logger takes about 1% of the time it takes to actually log. -- James Stauffer http://www.geocities.com/stauffer_james/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]