| re: Writing to one trace file from Web Service
Maybe you need to add the relevant objects to application state or session
state or whatever is appropriate.
Then when a web method is invoked, retrieve the objects and use them.
--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Wilfried Hoermann" <nnamroeh@nowhere.com> wrote in message
news:0fee01c38cb7$dd461f90$a101280a@phx.gbl...[color=blue]
> 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();
> }[/color] |