开发者

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?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜