开发者

Adding messages to trace log in WCF service?

开发者 https://www.devze.com 2023-02-12 17:50 出处:网络
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 a

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

精彩评论

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