LogImplIsDebugEnabled Property Apache log4net™ SDK Documentation
Checks if this logger is enabled for the DEBUG level.

Namespace: log4net.Core
Assembly: log4net (in log4net.dll) Version: 4.0

public virtual bool IsDebugEnabled { get; }

Property Value

Type: Boolean
true if this logger is enabled for DEBUG events, false otherwise.



This function is intended to lessen the computational cost of disabled log debug statements.

For some log Logger object, when you write:

log.Debug("This is entry number: " + i );

You incur the cost constructing the message, concatenation in this case, regardless of whether the message is logged or not.

If you are worried about speed, then you should write:

if (log.IsDebugEnabled())
 log.Debug("This is entry number: " + i );

This way you will not incur the cost of parameter construction if debugging is disabled for log. On the other hand, if the log is debug enabled, you will incur the cost of evaluating whether the logger is debug enabled twice. Once in IsDebugEnabled and once in the Debug. This is an insignificant overhead since evaluating a logger takes about 1% of the time it takes to actually log.

See Also