You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Stephen Levinson <St...@sun.com> on 2001/09/10 21:54:28 UTC

isDebugEnabled()

Hi all...

	There are methods isDebugEnabled() and isInfoEnabled() for avoiding
performance penalties when tracing is turned up high... but there are NO
corresponding methods isWarnEnabled() and isErrorEnabled(). These could be
easily written.. however, I'm wondering why they aren't in the package. Any
help?

Thanks, Stephen

==============================================
Stephen Levinson                    
SUN Microsystems Engineering 
199 Forest St.				
Marlborough, MA 01752
Phone: 508-460-5152 X187
FAX: 508-460-5153
==============================================


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: isDebugEnabled()

Posted by Ganapathi Raman <ma...@yahoo.com>.
 Hi Steve,
We use isDebugEnabledFor() and isInfoEnabledFor() in our application...the primary aim of these methods is during production move...when ur application goes into production you would normally not want ur debug and info messages. So you would set the appropriate priority to the category to disable info and debug statements. Consider a small secnario:
cat.debug("I got string1"+stringObject1+" and string2 "+stringObject2+" from DB!");
Here, before the string is passed on for logging, there is some time spent in string concatenation. This might be useful while debugging but in case of production, when you do not want this message to appear, what would happen is that the string is constructed and passed over only to find that the category is not enabled for debug logging. To save this processing time we initially itself check as:
if (cat.isDebugEnabled()){
cat.debug("I got string1"+stringObject1+" and string2 "+stringObject2+" from DB!");

}
But in case of error or fatal or warn, in production environment also you may need those information when some part of your code bombs. 
IMHO i feel that this may be the primary cause behind not having isWarnEnabled() and isErrorEnabled()..even though in case you want you can use isEnabledFor(org.apache.log4j.Priority) method.
Any comments/ suggestions??
regards,
ganapathi.
 
  Stephen Levinson <St...@sun.com> wrote: Hi all...

There are methods isDebugEnabled() and isInfoEnabled() for avoiding
performance penalties when tracing is turned up high... but there are NO
corresponding methods isWarnEnabled() and isErrorEnabled(). These could be
easily written.. however, I'm wondering why they aren't in the package. Any
help?

Thanks, Stephen

==============================================
Stephen Levinson 
SUN Microsystems Engineering 
199 Forest St. 
Marlborough, MA 01752
Phone: 508-460-5152 X187
FAX: 508-460-5153
==============================================


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org



---------------------------------
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger.