NLog.LogFactory.DisableLogging C# (CSharp) Method

DisableLogging() public method

Decreases the log enable counter and if it reaches -1 the logs are disabled.
Logging is enabled if the number of EnableLogging calls is greater than or equal to DisableLogging calls.
public DisableLogging ( ) : IDisposable
return IDisposable
        public IDisposable DisableLogging()
        {
            lock (this)
            {
                this.logsEnabled--;
                if (this.logsEnabled == -1)
                {
                    this.ReconfigExistingLoggers();
                }
            }

            return new LogEnabler(this);
        }

Usage Example

Example #1
0
 /// <summary>Decreases the log enable counter and if it reaches -1
 /// the logs are disabled.</summary>
 /// <remarks>Logging is enabled if the number of <see cref="EnableLogging"/> calls is greater
 /// than or equal to <see cref="DisableLogging"/> calls.</remarks>
 /// <returns>An object that iplements IDisposable whose Dispose() method
 /// reenables logging. To be used with C# <c>using ()</c> statement.</returns>
 public static IDisposable DisableLogging()
 {
     return(globalFactory.DisableLogging());
 }