开发者

Adding messages to trace log in WCF service?

If I have trace logging enabled on a WCF 开发者_JS百科service is it possible to write custom messages to it? If so how? If I don't have trace logging enabled will it just not write or will it throw an exception?


You can use below code:

FileStream traceLog = new FileStream("C:\\log\\Traces.svclog",FileMode.OpenOrCreate);

TextWriterTraceListener myListener = new TextWriterTraceListener(traceLog);

Trace.Listeners.Add(myListener);

myListener.WriteLine("Sending trace information");

Trace.Flush();

myListener.Flush();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜