Hi Michael,
As for the TextTraceListener, based on my research, the undelying Writer it
used is hard coded as "StreamWriter" and use the "initliazeData" to get the
log file path. Therefore, I'm afraid this class is not supposed to let you
change different kind of underlying writer. For such scenario,
implementing a custom Tracelistener should be the reasonable approach:
#Implementing a Custom TraceListener
http://www.codeguru.com/vb/gen/vb_misc/debuggingandtracing/article.php/c5611
/
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <m_j_sorens@newsgroup.nospam>
>Subject: Initializing a TraceListener Writer to a stream in app.config.
>Date: Mon, 18 Feb 2008 15:36:00 -0800
>I would like to be able to define a TraceListener in my app.config file whose
>Writer is a stream. I understand how to do this in code, but I have not been
[quoted text clipped - 3 lines]
>the TraceSource configuration generates a ConfigurationErrorsException. That
>is, if I attempt to assign a Writer like this:
((TextWriterTraceListener)mySource.Listeners["ExperimentalListener"]).Writer
= strWriter = new StringWriter();
>I get the aforementioned exception.
>
>Is there a way to initialize the Writer to a StringWriter within the
>app.config file itself?
>
>[My environment: .NET 2.0, VS2005]
michael sorens - 19 Feb 2008 19:27 GMT
I thought that might be the case. I found, however, that if I specify a dummy
filename in the app.config, then during my program initialization I could
re-assign the Writer to be a StringWriter.
Steven Cheng - 20 Feb 2008 01:31 GMT
Thanks for your reply Michael,
Sounds like a workable trick. Anyway, glad that you've got it working.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <m_j_sorens@newsgroup.nospam>
>References: <0BB6E876-46C2-435F-8098-BA8DD51F370B@microsoft.com>
<n3yyTOucIHA.5204@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Initializing a TraceListener Writer to a stream in app.config.
>Date: Tue, 19 Feb 2008 11:27:02 -0800
>I thought that might be the case. I found, however, that if I specify a dummy
>filename in the app.config, then during my program initialization I could
>re-assign the Writer to be a StringWriter.