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: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    public virtual bool IsDebugEnabled { get; }

    Public Overridable ReadOnly Property IsDebugEnabled As Boolean
    	Get

    public:
    virtual property bool IsDebugEnabled {
    	bool get ();
    }

    abstract IsDebugEnabled : bool with get
    override IsDebugEnabled : bool with get

#### Property Value

Type: Boolean
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#
Copy

    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#
Copy

    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

#### Reference

LogImpl Class
log4net.Core Namespace