C# Class NLog.Targets.DatabaseTarget

Inheritance: Target
Afficher le fichier Open project: NLog/NLog Class Usage Examples

Private Properties

Свойство Type Description
CloseConnection void
EnsureConnectionOpen void
InitializeTarget void
OpenConnection IDbConnection
RunInstallCommands void
WriteEventToDatabase void

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode 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 méthode

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.
Résultat string

CloseTarget() protected méthode

Closes the target and releases any unmanaged resources.
protected CloseTarget ( ) : void
Résultat void

DatabaseTarget() public méthode

Initializes a new instance of the DatabaseTarget class.
public DatabaseTarget ( ) : System
Résultat System

DatabaseTarget() public méthode

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

Install() public méthode

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

IsInstalled() public méthode

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

Uninstall() public méthode

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

Write() protected méthode

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.
Résultat void

Write() protected méthode

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.
Résultat void