C# Class NLog.Targets.DatabaseTarget

Inheritance: Target
Exibir arquivo Open project: NLog/NLog Class Usage Examples

Private Properties

Property Type Description
CloseConnection void
EnsureConnectionOpen void
InitializeTarget void
OpenConnection IDbConnection
RunInstallCommands void
WriteEventToDatabase void

Public Methods

Method Description
DatabaseTarget ( ) : System

Initializes a new instance of the DatabaseTarget class.

DatabaseTarget ( string name ) : System

Initializes a new instance of the DatabaseTarget class.

Install ( InstallationContext installationContext ) : void

Performs installation which requires administrative permissions.

IsInstalled ( InstallationContext installationContext ) : bool?

Determines whether the item is installed.

Uninstall ( InstallationContext installationContext ) : void

Performs uninstallation which requires administrative permissions.

Protected Methods

Method Description
BuildConnectionString ( LogEventInfo logEvent ) : string

Build the connectionstring from the properties.

Using ConnectionString at first, and falls back to the properties DBHost, DBUserName, DBPassword and DBDatabase

CloseTarget ( ) : void

Closes the target and releases any unmanaged resources.

Write ( AsyncLogEventInfo logEvents ) : void

Writes an array of logging events to the log target. By default it iterates on all events and passes them to "Write" method. Inheriting classes can use this method to optimize batch writes.

Write ( LogEventInfo logEvent ) : void

Writes the specified logging event to the database. It creates a new database command, prepares parameters for it by calculating layouts and executes the command.

Private Methods

Method Description
CloseConnection ( ) : void
EnsureConnectionOpen ( string connectionString ) : void
InitializeTarget ( ) : void
OpenConnection ( string connectionString ) : IDbConnection
RunInstallCommands ( InstallationContext installationContext, IEnumerable commands ) : void
WriteEventToDatabase ( LogEventInfo logEvent ) : void

Method Details

BuildConnectionString() protected method

Build the connectionstring from the properties.
Using ConnectionString at first, and falls back to the properties DBHost, DBUserName, DBPassword and DBDatabase
protected BuildConnectionString ( LogEventInfo logEvent ) : string
logEvent LogEventInfo Event to render the layout inside the properties.
return string

CloseTarget() protected method

Closes the target and releases any unmanaged resources.
protected CloseTarget ( ) : void
return void

DatabaseTarget() public method

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

DatabaseTarget() public method

Initializes a new instance of the DatabaseTarget class.
public DatabaseTarget ( string name ) : System
name string Name of the target.
return System

Install() public method

Performs installation which requires administrative permissions.
public Install ( InstallationContext installationContext ) : void
installationContext NLog.Config.InstallationContext The installation context.
return void

IsInstalled() public method

Determines whether the item is installed.
public IsInstalled ( InstallationContext installationContext ) : bool?
installationContext NLog.Config.InstallationContext The installation context.
return bool?

Uninstall() public method

Performs uninstallation which requires administrative permissions.
public Uninstall ( InstallationContext installationContext ) : void
installationContext NLog.Config.InstallationContext The installation context.
return void

Write() protected method

Writes an array of logging events to the log target. By default it iterates on all events and passes them to "Write" method. Inheriting classes can use this method to optimize batch writes.
protected Write ( AsyncLogEventInfo logEvents ) : void
logEvents AsyncLogEventInfo Logging events to be written out.
return void

Write() protected method

Writes the specified logging event to the database. It creates a new database command, prepares parameters for it by calculating layouts and executes the command.
protected Write ( LogEventInfo logEvent ) : void
logEvent LogEventInfo The logging event.
return void