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 Bret Schuhmacher <br...@ingrian.com> on 2007/06/15 14:28:39 UTC
isFatalEnabled()?
There are methods for isDebugEnabled and isInfoEnabled, but how do you
check for isFatalEnabled or any of the other levels? I've used
isEnabledFor(Priority.<level>), but Priority.FATAL and the rest are
deprecated, so what's the best way to test for the unrepresented
is<Level>Enabled levels?
Thanks,
Bret
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: isFatalEnabled()?
Posted by Bret Schuhmacher <br...@ingrian.com>.
Thanks, Endre - that makes sense. Yes, I was trying to test so I wouldn't have to do any String concatenation and processing if the level was turned off. Guess I was getting pretty anal ;-). TRACE, DEBUG, and INFO ought to be enough.
Rgds,
Bret
--
> -----Original Message-----
> From: Endre Stølsvik [mailto:Endre@stolsvik.com]
> Sent: Friday, June 15, 2007 9:36 AM
> To: Log4J Users List
> Subject: Re: isFatalEnabled()?
>
> Bret Schuhmacher wrote:
> > There are methods for isDebugEnabled and isInfoEnabled, but how do
> you
> > check for isFatalEnabled or any of the other levels? I've used
> > isEnabledFor(Priority.<level>), but Priority.FATAL and the rest are
> > deprecated, so what's the best way to test for the unrepresented
> > is<Level>Enabled levels?
>
> There is isTraceEnbled too.
>
> Just don't bother to test for them externally - they are always checked
> for inside log4j at any rate. It is assumed that there are rather few
> warnings, errors and fatals throughout an application, and that they
> mostly won't be turned off anyway, thus there isn't much need for the
> isEnabled methods. Those methods are only there to enable argument-
> construction bypass - that is, not having to actually make the log-
> message if logging for the particular level is turned off.
>
> Endre.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: isFatalEnabled()?
Posted by Wayne Cannon <wc...@turinnetworks.com>.
It's best to check for "isDebugEnabled", etc., externally if performance
is a consideration, since an external test avoids the time-consuming
concatenating and formatting strings if it won't be used. If you use
the test inside log4j, you will pay the penalty for these operations,
even if they are not going to be logged. This ability is a key feature
of log4j and all other good logging systems. --Wayne
Endre Stølsvik wrote:
> Bret Schuhmacher wrote:
>> There are methods for isDebugEnabled and isInfoEnabled, but how do you
>> check for isFatalEnabled or any of the other levels? I've used
>> isEnabledFor(Priority.<level>), but Priority.FATAL and the rest are
>> deprecated, so what's the best way to test for the unrepresented
>> is<Level>Enabled levels?
>
> There is isTraceEnbled too.
>
> Just don't bother to test for them externally - they are always
> checked for inside log4j at any rate. It is assumed that there are
> rather few warnings, errors and fatals throughout an application, and
> that they mostly won't be turned off anyway, thus there isn't much
> need for the isEnabled methods. Those methods are only there to enable
> argument-construction bypass - that is, not having to actually make
> the log-message if logging for the particular level is turned off.
>
> Endre.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: isFatalEnabled()?
Posted by Endre Stølsvik <En...@stolsvik.com>.
Bret Schuhmacher wrote:
> There are methods for isDebugEnabled and isInfoEnabled, but how do you
> check for isFatalEnabled or any of the other levels? I've used
> isEnabledFor(Priority.<level>), but Priority.FATAL and the rest are
> deprecated, so what's the best way to test for the unrepresented
> is<Level>Enabled levels?
There is isTraceEnbled too.
Just don't bother to test for them externally - they are always checked
for inside log4j at any rate. It is assumed that there are rather few
warnings, errors and fatals throughout an application, and that they
mostly won't be turned off anyway, thus there isn't much need for the
isEnabled methods. Those methods are only there to enable
argument-construction bypass - that is, not having to actually make the
log-message if logging for the particular level is turned off.
Endre.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: isFatalEnabled()?
Posted by Curt Arnold <ca...@apache.org>.
On Jun 15, 2007, at 7:28 AM, Bret Schuhmacher wrote:
> There are methods for isDebugEnabled and isInfoEnabled, but how do you
> check for isFatalEnabled or any of the other levels? I've used
> isEnabledFor(Priority.<level>), but Priority.FATAL and the rest are
> deprecated, so what's the best way to test for the unrepresented
> is<Level>Enabled levels?
>
> Thanks,
>
As other posters have mentioned, error and fatal errors should occur
infrequently enough that you don't try to optimize their performance
by trying to minimize unnecessary formatting and concatenations/
However, you can check if any arbitrary level is enabled by using
Logger.isEnabledFor().
Logger.isEnabledFor(Level.FATAL);
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org