FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit ae60bde4 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Fix eventlog source name

By default, an eventsource of WpkgInstaller gets created in the
Application log. We have to use a different eventsource name.
parent b1834c04
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@
//
// eventLog
//
this.eventLog.MachineName = ".eventLog";
this.eventLog.EntryWritten += new System.Diagnostics.EntryWrittenEventHandler(this.eventLog_EntryWritten);
//
// WpkgInstaller
......
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Diagnostics;
using System;
namespace WpkgInstaller
{
......@@ -33,17 +35,24 @@ namespace WpkgInstaller
public WpkgInstaller()
{
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("WpkgInstaller"))
eventLog = new EventLog();
string eventSourceName = "WpkgInstaller Service";
string logName = "WpkgNotifier";
if (!EventLog.SourceExists(eventSourceName))
{
System.Diagnostics.EventLog.CreateEventSource(
"WpkgInstaller", "WpkgNotifier");
EventLog.CreateEventSource(eventSourceName, logName);
}
eventLog.Source = "WpkgNotifier";
eventLog.Log = "WpkgInstaller";
eventLog.Source = eventSourceName;
eventLog.Log = logName;
}
protected override void OnStart(string[] args)
{
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 100000;
......@@ -52,7 +61,7 @@ namespace WpkgInstaller
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
eventLog.WriteEntry("Service started");
eventLog.WriteEntry("Service started", EventLogEntryType.Information);
}
protected override void OnStop()
......@@ -65,12 +74,13 @@ namespace WpkgInstaller
serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
eventLog.WriteEntry("Service stopped");
eventLog.WriteEntry("Service stopped", EventLogEntryType.Information);
}
private void eventLog_EntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e)
{
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment