Apache log4net� SDK Documentation - Microsoft .NET Framework 4.0

LogImpl.IsDebugEnabled Property

Checks if this logger is enabled for the DEBUG level.

[Visual�Basic]
Overridable�Public�ReadOnly�Property�IsDebugEnabled�As�Boolean�_
����Implements�ILog.IsDebugEnabled
[C#]
public�virtual�bool�IsDebugEnabled�{get;}

Property Value

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:

[C#]
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:

[C#]
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

LogImpl Class | log4net.Core Namespace