开发者

How to access services logs from my C# test?

There is a WCF service that I'm testing. When the service completes it posts its results on an application services log- I can see the message in the Event Viewer.

I'd like to monitor the log and read the log entry from my test program, but I haven't been able to f开发者_如何学Cigure out the best way to do that. I've searched through StackOverflow archives and Google. Can someone point me in the right direction? I'm coding in C#. Thanks.


Microsoft has a KB article on how to read event log entries from code:

http://msdn.microsoft.com/en-us/library/k6b9a7h8(v=VS.90).aspx

In short:

// Create an EventLog instance and assign its log name.
EventLog myLog = new EventLog("MyLogName");

// Read the event log entries.
foreach (EventLogEntry entry in myLog.Entries)
{
    Console.WriteLine("\tEntry: " + entry.Message);
}

(code from http://msdn.microsoft.com/en-us/library/f9hdxtte.aspx)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜