Presumably a trivial question...
I want to write trace information from a web service to a
log file using the Trace Class. Is this possible without
closing and opening the Trace in every single web method?
Code:
public Webservice()
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Constructor " +
System.DateTime.Now.ToString());
Trace.Close();
[WebMethod]
public WebMethod ()
{
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Method " +
System.DateTime.Now.ToString());
Trace.Close();
}