C# Class NLog.Config.XmlLoggingConfiguration

A class for configuring NLog through an XML configuration file (App.config style or App.nlog style).
Inheritance: LoggingConfiguration
Show file Open project: NLog/NLog Class Usage Examples

Private Properties

Property Type Description
AddArrayItemFromElement bool
CheckParsingErrors void
CheckUnusedTargets void
CleanSpaces string
ConfigureFromFile void
ConfigureObjectFromAttributes void
ConfigureObjectFromElement void
CreateFileReader XmlReader
ExpandSimpleVariables string
GetFileLookupKey string
Initialize void
IsTargetElement bool
IsTargetRefElement bool
ParseConfigurationElement void
ParseExtensionsElement void
ParseFilters void
ParseIncludeElement void
ParseLoggerElement void
ParseNLogElement void
ParseRulesElement void
ParseTargetElement void
ParseTargetsElement void
ParseTimeElement void
ParseTopLevel void
ParseVariableElement void
SetItemFromElement bool
SetLayoutFromElement bool
SetPropertyFromElement void
StripOptionalNamespacePrefix string
TryCreateLayoutInstance NLog.Layouts.Layout
WrapWithAsyncTargetWrapper NLog.Targets.Target
WrapWithDefaultWrapper NLog.Targets.Target
XmlLoggingConfiguration System
XmlLoggingConfiguration System

Public Methods

Method Description
GetCandidateConfigFilePaths ( ) : IEnumerable

Get file paths (including filename) for the possible NLog config files.

Reload ( ) : LoggingConfiguration

Re-reads the original configuration file and returns the new LoggingConfiguration object.

ResetCandidateConfigFilePath ( ) : void

Clear the candidate file paths and return to the defaults.

SetCandidateConfigFilePaths ( IEnumerable filePaths ) : void

Overwrite the paths (including filename) for the possible NLog config files.

XmlLoggingConfiguration ( XmlReader reader, string fileName ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( XmlReader reader, string fileName, LogFactory logFactory ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( XmlReader reader, string fileName, bool ignoreErrors ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( XmlReader reader, string fileName, bool ignoreErrors, LogFactory logFactory ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( string fileName ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( string fileName, LogFactory logFactory ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( string fileName, bool ignoreErrors ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( string fileName, bool ignoreErrors, LogFactory logFactory ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

Private Methods

Method Description
AddArrayItemFromElement ( object o, NLog.Config.NLogXmlElement element ) : bool
CheckParsingErrors ( NLog.Config.NLogXmlElement rootContentElement ) : void

Checks whether any error during XML configuration parsing has occured. If there are any and ThrowConfigExceptions or ThrowExceptions setting is enabled - throws NLogConfigurationException, otherwise just write an internal log at Warn level.

CheckUnusedTargets ( ) : void

Checks whether unused targets exist. If found any, just write an internal log at Warn level. If initializing not started or failed, then checking process will be canceled

CleanSpaces ( string s ) : string

Remove all spaces, also in between text.

Tabs and other whitespace is not removed!

ConfigureFromFile ( string fileName, bool autoReloadDefault ) : void
ConfigureObjectFromAttributes ( object targetObject, NLog.Config.NLogXmlElement element, bool ignoreType ) : void
ConfigureObjectFromElement ( object targetObject, NLog.Config.NLogXmlElement element ) : void
CreateFileReader ( string fileName ) : XmlReader

Create XML reader for (xml config) file.

ExpandSimpleVariables ( string input ) : string

Replace a simple variable with a value. The orginal value is removed and thus we cannot redo this in a later stage. Use for that: VariableLayoutRenderer

GetFileLookupKey ( string fileName ) : string
Initialize ( XmlReader reader, string fileName, bool ignoreErrors ) : void

Initializes the configuration.

IsTargetElement ( string name ) : bool
IsTargetRefElement ( string name ) : bool
ParseConfigurationElement ( NLog.Config.NLogXmlElement configurationElement, string filePath, bool autoReloadDefault ) : void

Parse {configuration} xml element.

ParseExtensionsElement ( NLog.Config.NLogXmlElement extensionsElement, string baseDirectory ) : void
ParseFilters ( LoggingRule rule, NLog.Config.NLogXmlElement filtersElement ) : void
ParseIncludeElement ( NLog.Config.NLogXmlElement includeElement, string baseDirectory, bool autoReloadDefault ) : void
ParseLoggerElement ( NLog.Config.NLogXmlElement loggerElement, IList rulesCollection ) : void

Parse {Logger} xml element

ParseNLogElement ( NLog.Config.NLogXmlElement nlogElement, string filePath, bool autoReloadDefault ) : void

Parse {NLog} xml element.

ParseRulesElement ( NLog.Config.NLogXmlElement rulesElement, IList rulesCollection ) : void

Parse {Rules} xml element

ParseTargetElement ( Target target, NLog.Config.NLogXmlElement targetElement ) : void
ParseTargetsElement ( NLog.Config.NLogXmlElement targetsElement ) : void
ParseTimeElement ( NLog.Config.NLogXmlElement timeElement ) : void
ParseTopLevel ( NLog.Config.NLogXmlElement content, string filePath, bool autoReloadDefault ) : void

Parse the root

ParseVariableElement ( NLog.Config.NLogXmlElement variableElement ) : void
SetItemFromElement ( object o, NLog.Config.NLogXmlElement element ) : bool
SetLayoutFromElement ( object o, NLog.Config.NLogXmlElement layoutElement ) : bool
SetPropertyFromElement ( object o, NLog.Config.NLogXmlElement element ) : void
StripOptionalNamespacePrefix ( string attributeValue ) : string

Remove the namespace (before :)

TryCreateLayoutInstance ( NLog.Config.NLogXmlElement element, Type type ) : Layout
WrapWithAsyncTargetWrapper ( Target target ) : Target
WrapWithDefaultWrapper ( Target t, NLog.Config.NLogXmlElement defaultParameters ) : Target
XmlLoggingConfiguration ( XmlElement element, string fileName ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

XmlLoggingConfiguration ( XmlElement element, string fileName, bool ignoreErrors ) : System

Initializes a new instance of the XmlLoggingConfiguration class.

Method Details

GetCandidateConfigFilePaths() public static method

Get file paths (including filename) for the possible NLog config files.
public static GetCandidateConfigFilePaths ( ) : IEnumerable
return IEnumerable

Reload() public method

Re-reads the original configuration file and returns the new LoggingConfiguration object.
public Reload ( ) : LoggingConfiguration
return LoggingConfiguration

ResetCandidateConfigFilePath() public static method

Clear the candidate file paths and return to the defaults.
public static ResetCandidateConfigFilePath ( ) : void
return void

SetCandidateConfigFilePaths() public static method

Overwrite the paths (including filename) for the possible NLog config files.
public static SetCandidateConfigFilePaths ( IEnumerable filePaths ) : void
filePaths IEnumerable The filepaths to the possible config file
return void

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( XmlReader reader, string fileName ) : System
reader XmlReader containing the configuration section.
fileName string Name of the file that contains the element (to be used as a base for including other files).
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( XmlReader reader, string fileName, LogFactory logFactory ) : System
reader XmlReader containing the configuration section.
fileName string Name of the file that contains the element (to be used as a base for including other files).
logFactory LogFactory The to which to apply any applicable configuration values.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( XmlReader reader, string fileName, bool ignoreErrors ) : System
reader XmlReader containing the configuration section.
fileName string Name of the file that contains the element (to be used as a base for including other files).
ignoreErrors bool Ignore any errors during configuration.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( XmlReader reader, string fileName, bool ignoreErrors, LogFactory logFactory ) : System
reader XmlReader containing the configuration section.
fileName string Name of the file that contains the element (to be used as a base for including other files).
ignoreErrors bool Ignore any errors during configuration.
logFactory LogFactory The to which to apply any applicable configuration values.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( string fileName ) : System
fileName string Configuration file to be read.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( string fileName, LogFactory logFactory ) : System
fileName string Configuration file to be read.
logFactory LogFactory The to which to apply any applicable configuration values.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( string fileName, bool ignoreErrors ) : System
fileName string Configuration file to be read.
ignoreErrors bool Ignore any errors during configuration.
return System

XmlLoggingConfiguration() public method

Initializes a new instance of the XmlLoggingConfiguration class.
public XmlLoggingConfiguration ( string fileName, bool ignoreErrors, LogFactory logFactory ) : System
fileName string Configuration file to be read.
ignoreErrors bool Ignore any errors during configuration.
logFactory LogFactory The to which to apply any applicable configuration values.
return System