1. PS.Framework.EventLogger

The assembly PS.Framework.EventLogger contains the EventLogManager.

With the EventLogManager its very easy to log errors or informations into the Windows EventLog or into a specified XML-File.
In this step its shown how easy it is to write log entries with the EventLogManager.

Setting up the configuration file
At first it's importand to configure the path to the configuration file of the EventLogManager. If no configuration file is configured the default location will be used.
In that case the location will be the application folder and the configuration file must be ConfigFile_Event.xml.
Otherwise the location of the config file must be added to the application configuration.

<?xml version="1.0" encoding="utf-8" ?>
    <add key="ConfigFile_Event" value="Configurations\ConfigFile_Event.xml"/>

Defining the configuration for a xml-file log:
<?xml version="1.0" encoding="utf-8" ?>
  <!-- The file where the log entries should be written to. - Free editable -->
  <!-- The Log Type - We have only two, XmlLog and EventLog in this case its the XmlLog-->

Defining the configuration for the Windows EventLog:
<?xml version="1.0" encoding="utf-8" ?>
  <!-- The Log Type - We have only two, XmlLog and EventLog in this case its the EventLog-->
  <!-- The event source -->
  <!-- The event log - needed to specify where to log inside the windows event log -->
  <EventLog>PS TestLog</EventLog>

Now there's all prepared for using the EventLogManager. Before the first use the EventLogManager must be initialized as shown below:

After initialization it's possible to write log entries from wherever you want in your application as shown below:
PSEV.WriteEvent("Application started successfull.", null, LogEntryType.SuccessAudit);

If you are using the LogType EventLog it's importand to uninitialize the EventLogManager as shown below:

Last edited Apr 26, 2012 at 5:56 PM by inflames2k, version 2


No comments yet.