开发者

Where goes my messages from service?

开发者 https://www.devze.com 2023-01-19 10:15 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消