C# Class NLog.LogFactory

Creates and manages instances of T:NLog.Logger objects.
Inheritance: IDisposable
Show file Open project: shiftkey/winrt-backport-hilarity Class Usage Examples

Public Methods

Method Description
CreateNullLogger ( ) : Logger

Creates a logger that discards all log messages.

DisableLogging ( ) : IDisposable

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.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

EnableLogging ( ) : void

Increases the log enable counter and if it reaches 0 the logs are disabled.

Logging is enabled if the number of EnableLogging calls is greater than or equal to DisableLogging calls.

Flush ( ) : void

Flush any pending log messages (in case of asynchronous targets).

Flush ( AsyncContinuation asyncContinuation ) : void

Flush any pending log messages (in case of asynchronous targets).

Flush ( AsyncContinuation asyncContinuation, System.TimeSpan timeout ) : void

Flush any pending log messages (in case of asynchronous targets).

Flush ( AsyncContinuation asyncContinuation, int timeoutMilliseconds ) : void

Flush any pending log messages (in case of asynchronous targets).

Flush ( System.TimeSpan timeout ) : void

Flush any pending log messages (in case of asynchronous targets).

Flush ( int timeoutMilliseconds ) : void

Flush any pending log messages (in case of asynchronous targets).

GetLogger ( string name ) : Logger

Gets the specified named logger.

GetLogger ( string name, Type loggerType ) : Logger

Gets the specified named logger.

IsLoggingEnabled ( ) : bool

Returns if logging is currently enabled.

Logging is enabled if the number of EnableLogging calls is greater than or equal to DisableLogging calls.

LogFactory ( ) : System

Initializes a new instance of the LogFactory class.

LogFactory ( LoggingConfiguration config ) : System

Initializes a new instance of the LogFactory class.

ReconfigExistingLoggers ( ) : void

Loops through all loggers previously returned by GetLogger and recalculates their target and filter list. Useful after modifying the configuration programmatically to ensure that all loggers have been properly configured.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases unmanaged and - optionally - managed resources.

Private Methods

Method Description
ConfigFileChanged ( object sender, EventArgs args ) : void
Dump ( LoggingConfiguration config ) : void
GetCandidateFileNames ( ) : IEnumerable
GetConfigurationForLogger ( string name, LoggingConfiguration configuration ) : LoggerConfiguration
GetCurrentClassLogger ( ) : Logger
GetCurrentClassLogger ( Type loggerType ) : Logger
GetLogger ( LoggerCacheKey cacheKey ) : Logger
GetTargetsByLevelForLogger ( string name, IList rules, NLog.Internal.TargetWithFilterChain targetsByLevel, NLog.Internal.TargetWithFilterChain lastTargetsByLevel ) : void
ReconfigExistingLoggers ( LoggingConfiguration configuration ) : void
ReloadConfigOnTimer ( object state ) : void

Method Details

CreateNullLogger() public method

Creates a logger that discards all log messages.
public CreateNullLogger ( ) : Logger
return Logger

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

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Dispose() protected method

Releases unmanaged and - optionally - managed resources.
protected Dispose ( bool disposing ) : void
disposing bool True to release both managed and unmanaged resources; false to release only unmanaged resources.
return void

EnableLogging() public method

Increases the log enable counter and if it reaches 0 the logs are disabled.
Logging is enabled if the number of EnableLogging calls is greater than or equal to DisableLogging calls.
public EnableLogging ( ) : void
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( ) : void
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( AsyncContinuation asyncContinuation ) : void
asyncContinuation AsyncContinuation The asynchronous continuation.
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( AsyncContinuation asyncContinuation, System.TimeSpan timeout ) : void
asyncContinuation AsyncContinuation The asynchronous continuation.
timeout System.TimeSpan Maximum time to allow for the flush. Any messages after that time will be discarded.
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( AsyncContinuation asyncContinuation, int timeoutMilliseconds ) : void
asyncContinuation AsyncContinuation The asynchronous continuation.
timeoutMilliseconds int Maximum time to allow for the flush. Any messages after that time will be discarded.
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( System.TimeSpan timeout ) : void
timeout System.TimeSpan Maximum time to allow for the flush. Any messages after that time will be discarded.
return void

Flush() public method

Flush any pending log messages (in case of asynchronous targets).
public Flush ( int timeoutMilliseconds ) : void
timeoutMilliseconds int Maximum time to allow for the flush. Any messages after that time will be discarded.
return void

GetLogger() public method

Gets the specified named logger.
public GetLogger ( string name ) : Logger
name string Name of the logger.
return Logger

GetLogger() public method

Gets the specified named logger.
public GetLogger ( string name, Type loggerType ) : Logger
name string Name of the logger.
loggerType System.Type The type of the logger to create. The type must inherit from NLog.Logger.
return Logger

IsLoggingEnabled() public method

Returns if logging is currently enabled.
Logging is enabled if the number of EnableLogging calls is greater than or equal to DisableLogging calls.
public IsLoggingEnabled ( ) : bool
return bool

LogFactory() public method

Initializes a new instance of the LogFactory class.
public LogFactory ( ) : System
return System

LogFactory() public method

Initializes a new instance of the LogFactory class.
public LogFactory ( LoggingConfiguration config ) : System
config NLog.Config.LoggingConfiguration The config.
return System

ReconfigExistingLoggers() public method

Loops through all loggers previously returned by GetLogger and recalculates their target and filter list. Useful after modifying the configuration programmatically to ensure that all loggers have been properly configured.
public ReconfigExistingLoggers ( ) : void
return void