From: Chris Leffer on
Hi.

How can I dynamically decide which trace listener to use? I tried to use
trace switches but it seems that I can't do that with switches.

Suppose the configuration file below:

<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="toFile" type="TextWriterTraceListener"
initializeData="App.log" />
<add name="toEvent" type="EventLogTraceListener"
initializeData="AppLog" />
</listeners>
</trace>
</system.diagnostics>

Is it possible to redirect the trace output to just one of them during
execution?

Best regards,
Chris Leffer



*** Sent via Developersdex http://www.developersdex.com ***
From: Patrice on
Hi,

Have you tried to you use <clear/> before adding those want ? See :
http://msdn.microsoft.com/en-us/library/ms229330.aspx for details...

Also it's unclear if you want to keep them both in the config file. If not
just comment the one you don't need and your app will use this one else you
could lokely change the listeners collection yourself based on your own
runtime criteria...

Which kind of app is this (Windows, ASP.NET) and what is your preferred
programming language ? (in case a code snippet would help understanding the
issue).

--
Patrice

"Chris Leffer" <chrisl(a)wank.com> a �crit dans le message de groupe de
discussion : ODePflpoKHA.3948(a)TK2MSFTNGP06.phx.gbl...
> Hi.
>
> How can I dynamically decide which trace listener to use? I tried to use
> trace switches but it seems that I can't do that with switches.
>
> Suppose the configuration file below:
>
> <system.diagnostics>
> <trace autoflush="true">
> <listeners>
> <add name="toFile" type="TextWriterTraceListener"
> initializeData="App.log" />
> <add name="toEvent" type="EventLogTraceListener"
> initializeData="AppLog" />
> </listeners>
> </trace>
> </system.diagnostics>
>
> Is it possible to redirect the trace output to just one of them during
> execution?
>
> Best regards,
> Chris Leffer
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


From: dotNetDave on
You can remove a trace listener during runtime via code, but to get it back
you would have to restart the app.

David

======================================
David McCarter [Microsoft MVP]
www.dotNetTips.com
David McCarter''''s .NET Coding Standards available at:
http://codingstandards.notlong.com


"Chris Leffer" wrote:

> Hi.
>
> How can I dynamically decide which trace listener to use? I tried to use
> trace switches but it seems that I can't do that with switches.
>
> Suppose the configuration file below:
>
> <system.diagnostics>
> <trace autoflush="true">
> <listeners>
> <add name="toFile" type="TextWriterTraceListener"
> initializeData="App.log" />
> <add name="toEvent" type="EventLogTraceListener"
> initializeData="AppLog" />
> </listeners>
> </trace>
> </system.diagnostics>
>
> Is it possible to redirect the trace output to just one of them during
> execution?
>
> Best regards,
> Chris Leffer
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> .
>