TN AppSvr205 Application Server and Windows Event Log Scripting
Description
This article from InSource shows how to write a script to read the Windows Event Log. This can be useful if searching for an error and wanting to generate an alarm or notification to someone to take action.
- Author: Lewis Talley
- Published: 09/01/2016
- Applies to: Application Server (Various)
Details
In the declarations section of the object type or paste the following text;
dim myLog as System.Diagnostics.EventLog;
dim entry as System.Diagnostics.EventLogEntry;
Create an attribute to trigger the script to run.
The body of the script is a follows (make sure to mark this script as asynchronous)
myLog = new System.Diagnostics.EventLog();
myLog.Source= "Application";
for each entry in myLog.Entries
logmessage (entry.Message);
if entry.EntryType == "Error" then
logmessage ("Error**************** " + entry.Message);
endif;
Next;
LogMessage ("**************************************" + entry.MachineName);
Me.Readlog = False;