View Single Post
  #4 (permalink)  
Old 07-23-2009, 07:01 AM
FrankBradley FrankBradley is offline
Junior Member
 
Join Date: Jun 2009
Posts: 29
Default

What we would like to be able to do is have a TASK create log entries within the Windows Even Log system. This is for server management and also to assist developers. The software does have a limited ability of generating a LOG file but this is an external text file that would require the creation of processes to collect the file and transfer that information.

Well we have added the ability by creating a C# application that is now being called from our TASK. As an example of what is being done.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Text;

namespace cs_logger
{
class Program
{
public static void Main(string[] args)
{
// Create the source, if it does not already exist.
String errorMessage = "Error Occurred: Critical Error has been flagged. Application has been terminated until the file critical_fault_sap has been removed";

if (!EventLog.SourceExists("csHdcAutomation", "."))
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog.CreateEventSource("csHdcAutomation","Cent ah",".");
// The source is created. Exit the application to allow it to be registered.
return;
}

// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "csHdcAutomation";
myLog.WriteEntry(errorMessage,EventLogEntryType.Er ror);
myLog.Close();

}
}
}


So the above code generates an entry in the Windows Event Log four our application that indicates an issue so that it is logged by the server management software and that will trigger other events that would correct what ever issue.

So being able to create Event log entries within the scripting environment would be very handy since it would reduce the overhead of including the 3rd application and execution.
__________________
Frank Bradley
Centah Inc
Reply With Quote