<PackageReference Include="NLog" Version="6.0.7" />

NLog.LogFactory

Creates and manages instances of Logger objects.
public bool AutoShutdown { get; set; }

Gets or sets a value indicating whether to automatically call Shutdown on AppDomain.Unload or AppDomain.ProcessExit

public LoggingConfiguration Configuration { get; set; }

Gets or sets the current logging configuration.

public CultureInfo DefaultCultureInfo { get; set; }

Gets or sets the default culture info to use as FormatProvider.

public LogLevel GlobalThreshold { get; set; }

Gets or sets the global log level threshold. Log events below this threshold are not logged.

public bool KeepVariablesOnReload { get; set; }

Gets or sets a value indicating whether Variables should be kept on configuration reload.

Repository of interfaces used by NLog to allow override for dependency injection

public bool? ThrowConfigExceptions { get; set; }

Gets or sets a value indicating whether NLogConfigurationException should be thrown. If null then ThrowExceptions is used.

public bool ThrowExceptions { get; set; }

Gets or sets a value indicating whether exceptions should be thrown. See also ThrowConfigExceptions.

Occurs when logging Configuration changes. Both when assigned to new config or config unloaded.

public LogFactory()

Initializes a new instance of the LogFactory class.

Obsolete instead use LogFactory default-constructor, and assign Configuration with NLog 5.0. Initializes a new instance of the LogFactory class.

Creates a logger that discards all log messages.

public void Dispose()

Shutdown logging

protected virtual void Dispose(bool disposing)

Shutdown logging without flushing async

Flush any pending log messages, and shutdown logging

public void Flush()

Flush any pending log messages (in case of asynchronous targets) with the default timeout of 15 seconds.

public void Flush(TimeSpan timeout)

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

public void Flush(int timeoutMilliseconds)

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

public void Flush(AsyncContinuation asyncContinuation)

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

public void Flush(AsyncContinuation asyncContinuation, int timeoutMilliseconds)

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

public void Flush(AsyncContinuation asyncContinuation, TimeSpan timeout)

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

public Task FlushAsync(CancellationToken cancellationToken)

Flush any pending log messages

Obsolete and replaced by Setup and LoadConfigurationFromFile with NLog v5.2. Get file paths (including filename) for the possible NLog config files.

Gets the logger with the full name of the current class, so namespace and class name.

public T GetCurrentClassLogger<T>() where T : Logger

Gets the logger with the full name of the current class, so namespace and class name. Use T to create instance of a custom Logger. If you haven't defined your own Logger class, then use the overload without the type parameter.

public Logger GetCurrentClassLogger(Type loggerType)

Obsolete and replaced by GetCurrentClassLogger<T> with NLog v5.2. Gets a custom logger with the full name of the current class, so namespace and class name. Use loggerType to create instance of a custom Logger. If you haven't defined your own Logger class, then use the overload without the loggerType.

public Logger GetLogger(string name)

Gets the specified named logger.

public T GetLogger<T>(string name) where T : Logger

Gets the specified named logger. Use T to create instance of a custom Logger. If you haven't defined your own Logger class, then use the overload without the type parameter.

public Logger GetLogger(string name, Type loggerType)

Obsolete and replaced by GetLogger<T> with NLog v5.2. Gets the specified named logger. Use loggerType to create instance of a custom Logger. If you haven't defined your own Logger class, then use the overload without the loggerType.

public bool IsLoggingEnabled()

Returns true if logging is currently enabled.

public LogFactory LoadConfiguration(string configFile)

Obsolete and replaced by Setup and LoadConfigurationFromFile with NLog v5.2. Loads logging configuration from file (Currently only XML configuration files supported)

Raises the event when the configuration is reloaded.

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 void ReconfigExistingLoggers(bool purgeObsoleteLoggers)

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.

Obsolete and replaced by Setup and LoadConfigurationFromFile with NLog v5.2. Clear the candidate file paths and return to the defaults.

public void ResumeLogging()

Resumes logging if having called SuspendLogging.

public void SetCandidateConfigFilePaths(IEnumerable<string> filePaths)

Obsolete and replaced by Setup and LoadConfigurationFromFile with NLog v5.2. Overwrite the candidates paths (including filename) for the possible NLog config files.

Begins configuration of the LogFactory options using fluent interface

public LogFactory Setup(Action<ISetupBuilder> setupBuilder)

Begins configuration of the LogFactory options using fluent interface

public void Shutdown()

Dispose all targets, and shutdown logging.

Suspends the logging, and returns object for using-scope so scope-exit calls ResumeLogging