EventLogWriter
The EventLogWriter component can be used to write entries of different types to windows event log. Using EventLogWriter component errors or important events occurring in event processes can be recorded to global, centralized event logs which can be viewed through windows event viewer.
Points to note
- This component runs only on Windows Platform.
- This component requires Microsoft .NET Framework 2.0 or above installed on the machine where peer server is running.
Configuration
Configure Component panel
The component can be configured using the properties in the Custom Property Sheet (CPS) shown in figure.
Figure 1: Sample EventLogWriter configuration with Expert Properties enabled and 'Use Message File' as "yes"
Attributes
Logger Name
The name of the log where the source's entries are written to. Possible values include: Application, System, or a custom event log name.
Source Name
The source name to register and use when writing to the event log
If a source name say for example "SampleApplication" has been registered to Logger Name "Application" and entries have been logged and if later again same source name "SampleApplication" is mapped to different Logger Name for example "CustomLog", entries will still be logged to logger "Application" till system restart.
Event Id
An identifier for the event. It can be any integral value between 0 and 65535
Category
Category associated with the message. Based on categories, events can be organized and filtered in event viewer. It can be any integral value between 0 and 32767. Category descriptions can be defined in a message file. 0 by default maps to description 'None'.
Event Type
Event type of the event log entry. Possible values are Information, FailureAudit, Error, SuccessAudit, Warning
Source Name, Event ID, Category and Event Type can also be provided from input which takes precedence over CPS values. If no value is provided for any property from input xml, values provided here will be used
Expert Properties
Target Namespace
Target Namespace to be used while generating input schema
Use Message File?
Enable this option to use category message file
Category Message File
Provide complete file path of message resource file on the system where component is running (eg : D:\EventLogMsgs.dll). Message files should contain description strings for each event category. This message file has to be compiled into a dll
Category Count
Number of categories defined in the resource file
Creating dll from a Message file
Following steps explain creation of dll from a Message file
Create a .mc file for example EventLogMsgs.mc as shown below containing descriptions for each categories consecutively starting from 1:
; // ******************************************************** ; // - Event categories - ; // Categories must be numbered consecutively starting at 1. ; // ******************************************************** MessageId=0x1 Language=English Category1 . MessageId=0x2 Language=English Category2 . MessageId=0x3 Language=English Category3 .
Use the following commands to build the message file to dll:
mc -s EventLogMsgs.mc
rc EventLogMsgs.rc
link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res
mc tool will be available as part of Microsoft Windows SDK tools installation and link will be part of Visual Studio installation
Error Handling Configuration
Please refer Error Handling section in Common Configurations page.
Testing
Input Schema
On finishing the configuration, following schema will be set on input port
Figure 2: Input Schema.
Functional Demonstration
Scenario 1
Log errors occurring within an event process to windows event log
Configure the EventLogWriter as mentioned above, provide the necessary mappings between error port and input port and use Display component to check the response.
Figure 3: Demonstrating Scenario 1