Hi Steve,
Based on my understanding, the problem you are facing is how to write the event log to a file named “SMSAIS�and the Source Name should be “SMS Atlas Integration� right?
As I can see from the code you provided, there’s no problem. But I can’t see how you write the logs from your windows service application. So I don’t know if the Source property of the EventLog is setup right.
Based on the code of this document, try to use the below method to log message, and see if you can get the desired result.
protected override void OnStart(string[] args)
{
if (!EventLog.SourceExists("SMS Atlas Integration"))
{
// 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("SMS Atlas Integration", "MyNewLog");
Console.WriteLine("CreatingEventSource");
Console.WriteLine("Exiting, execute the application a second time to use the source.");
// The source is created. Exit the application to allow it to be registered.
}
// Create an EventLog instance and assign its source.
myLog.Source = "SMS Atlas Integration";
// Write an informational entry to the event log.
myLog.WriteEntry("service is started");
}
protected override void OnStop()
{
myLog.WriteEntry("service is stoped");
}
If I have misunderstood you or the problem can’t be solved, please feel free to let me know.
Best regards,
Bruce Zhou
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.