Where goes my messages from service?
In C# VS2008 I have a service which can run from command line and as registered service. I am trying to debug my Service process I wondered why it does not write logs in event viewer. I have a logger as this:
public static void Log(string s, EventLogEntryType et) {
try {
if (CService.asService) {
if (!EventLog.SourceExists("Jobs")) {
EventLog.CreateEventSource("Jobs", "JobsServiceLog");
开发者_如何学C }
EventLog.WriteEntry("Jobs", s,
et, 234);
}
else {
Console.WriteLine(s);
}
}
catch { }
}
Then somewhere I am logging: Log("Jobs service started", EventLogEntryType.Information);
Nothing is appear in the Event Viewer->JobsServiceLog.
What can be reason?
thanks
Arman.
What's up with CService.asService? are you sure the source gets created?
精彩评论