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

Namespace: log4net.Core
Assembly: log4net (in log4net.dll) Version: 1.2.15.0 (1.2.15.0)
Syntax

public virtual bool IsDebugEnabled { get; }

Property Value

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

Implements

ILog IsDebugEnabled
Remarks

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