Trace Listeners

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 ***
0
Chris
1/31/2010 5:18:12 PM
dotnet.general 306 articles. 0 followers. Follow

3 Replies
763 Views

Similar Articles

[PageSpeed] 53

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@wank.com> a �crit dans le message de groupe de 
discussion : ODePflpoKHA.3948@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 *** 


0
Patrice
2/1/2010 3:10:25 PM
I'm not sure If I understand the question correctly.
If you are trying to figure out how to programmatically attach default
or custom trace listeners at runtime you should read this:
http://msdn.microsoft.com/en-us/library/sk36c28t(VS.80).aspx
http://www.codeproject.com/KB/dotnet/customnettracelisteners.aspx

Good Luck, Sebastian

On 1 Feb., 16:10, "Patrice" <http://scribe-en.blogspot.com/> wrote:
> Hi,
>
> Have you tried to you use <clear/> before adding those want ? See :http:/=
/msdn.microsoft.com/en-us/library/ms229330.aspxfor details...
>
> Also it's unclear if you want to keep them both in the config file. If no=
t
> just comment the one you don't need and your app will use this one else y=
ou
> 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 t=
he
> issue).
>
> --
> Patrice
>
> "Chris Leffer" <chr...@wank.com> a =E9crit dans le message de groupe de
> discussion : ODePflpoKHA.3...@TK2MSFTNGP06.phx.gbl...
>
>
>
> > Hi.
>
> > How can I dynamically decide which trace listener to use? I tried to us=
e
> > trace switches but it seems that I can't do that with switches.
>
> > Suppose the configuration file below:
>
> > <system.diagnostics>
> > =A0<trace autoflush=3D"true">
> > =A0 =A0<listeners>
> > <add name=3D"toFile" type=3D"TextWriterTraceListener"
> > initializeData=3D"App.log" />
> > <add name=3D"toEvent" type=3D"EventLogTraceListener"
> > initializeData=3D"AppLog" />
> > =A0 =A0</listeners>
> > =A0</trace>
> > </system.diagnostics>
>
> > Is it possible to redirect the trace output to just one of them during
> > execution?
>
> > Best regards,
> > Chris Leffer
>
> > *** Sent via Developersdexhttp://www.developersdex.com***- Zitierten Te=
xt ausblenden -
>
> - Zitierten Text anzeigen -

0
sebastian
2/4/2010 7:05:10 AM
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 ***
> .
> 
0
Utf
2/22/2010 8:44:01 PM
Reply:

Similar Artilces:

Attachment event tracing
HI, I have developed a custom form of IPM.Note Message class, the functionality goes like this, the initiator of form attaches several documents to the form and specifies the list of users to which the form has to be sent in sequence for feedback on the attached documents (which is edited and saved back to the attachments of form). This form carries these updated attachments to each user in series till the last user and then backs to the initiator. My problem is, if the user has opened the attachment and forgets to save and close, he clicks on the process button on form to next user, I need ...

TRACE
Hi, Could you tell me which is the Win32 [or perheps, more correctly, non-MFC] equivalent of MFC's TRACE macro. Thanks very much. -- ====== Arman I think you can use OutputDebugString() in a purely win32 application. -Seetharam Misro Ok, it worked. Thanks. -- ====== Arman "Seetharam" wrote: > I think you can use OutputDebugString() in a purely win32 application. > > -Seetharam Misro > > There isn't really one that has the properties of formatting, conditional compilation, and output to the debug port. OutputDebugString is the Win32 API, ...

tracing precedents and dependents
HI folks, I'm using the auditing tool to trace precedents and dependents to a cell. Problem is if the precedent or dependents are on another sheet, it won't tell me which sheets and which cells are dependent to the cell I am examining. Is there a way to find this out? any improvements to this tool out there? thanks Just doubleclick on the line linking the little spreadsheet box you can see -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ------------------------------------------------------------...

MFC Socket listener
Hello everyone, got a quick question here that hopefully someone can help me with. Basically I am having trouble with my Client application which uses MFC CSockets. I currently can only listen to one port (say 4000), and I need to be able to listen to multiple ports. Originally I just set up two listeners (one listening on 4000 another on 4200) but the problem with this is that I need to know which Listener is flagged when I call the OnAccept() method (actually this method is calling another function OnProcessPendingAccept() at which point I need to know which listener got tagged). Basical...

Trace Precedents (Saving Tracing to print)
Hello, I audit and give spreadsheets to be audited by someone else eveyday. I use the trace precedents/dependents frequently in Excel 2000 for me to see where caclulations are coming from. Is there a way to keep all the cells that I trace from losing the blue trace line when I recalculate the sheet? I would like to be able to print the tracing on my sheet so it is easier for others to follow where certain numbers are being calculated from. Kevin ...

Tracing Automatic Links
I have received an Excel workbook of prices. Upon opening it, I get the message that there are automatic links to another workbook. I selecty "no" to keep the existing info. My question is: how do I trace where these links occur in the workbook, I want to trace them and see what is supposed to update. Thanks --- Message posted from http://www.ExcelForum.com/ one way would be to Edit > Find: Find '[' and Look in Formula -- Message posted from http://www.ExcelForum.com ...

TRACE with VS6 onVista
Hello, I have recently upgraded to MS Vista and TRACE makro is not working since then. I am getting no output from it. Any ideas? Thank you Vaclav Due to serious bugs in VS.NET and beyond, trace output gets dropped; anything that does an incremental compilation stops TRACE output. This is a deep design error with the "improved" IDE, and is consistent with what we have come to expect with new releases of VS: they are overall less reliable, have more bugs, more serious bugs, and are less usable than the version that preceded them. joe On Sun, 17 Jun 2007 11:41:57 +0200, V�c...

Track and trace
I have received a document that has been through the track and trace. It is filled with format changes, so can I, in any way, accept just the formatting changes in one stroke? I normally tick off the formatting, but it does not work, once they are there. Hope someone understands my question, because the document is rather difficult to work with when all the formats are marked several times each line. Thank you To get rid of the markup, accept all changes in the document and then turn off Track Changes. If you are using Word 2003, see http://www.shaunakelly.com/word/trackchanges/...

Set up trace
Hello, [SQL2005] I want to setup a trace and capture Deadlock information. However I do not want to use SQL profiler and instead write T-SQL to accomplish this. The trace output should go to a table. When I checked sp_trace_create, it does not mention about having table as output. When I created a trace in profiler and exported the script, it mentions that "-- Client side File and Table cannot be scripted" How can I accomplish this? TIA, AbbA A server-side trace can only go to file, not table. -- Tibor Karaszi, SQL Server MVP http://www.karaszi.co...

Contact's within accounts
Hi everyone, I would appreciate any help on this. I need to know what to look for in CRM application error reporting to try and identify the root cause of my problem. The error itself is something which has been the topic of numerous threads on this forum, however I have not been able to resolve the issue. When I open an account and create a new contact entity, then try to save and close it, I receive the error stack trace below. Would anyone please let me know if you can see where the problem is or what I can look for to try and resolve it. I've checked and re-checked my mappings...

Trace Linked cell
How do I trace only linked cell those are liked with another sheet or file to break unnecessary link regards Edit>Links may do the job. If no joy with that................... Download and use Bill Manville's FindLink add-in. http://www.oaltd.co.uk/MVP/Default.htm Gord Dibben MS Excel MVP On Tue, 27 Apr 2010 07:02:01 -0700, vlook fomula <vlookfomula@discussions.microsoft.com> wrote: >How do I trace only linked cell those are liked with another sheet or file to >break unnecessary link > >regards Edit>Links may do the job. ...

ok to disable trace verbs?
Does exh 2003 need http trace method verbs enabled in iis for any reason? Ok to disable them? If you are thinking about locking down IIS so that it only supports specific verbs, I don't *think* that the TRACE verb is required. I'm basing this on a recommended OWA configuration for the URLSCAN.INI. See KB 309508 for more information. -- Jim McBee - MostlyExchange Blog: http://mostlyexchange.blogspot.com - Exchange FAQ: http://www.swinc.com/resources/exchange/ "ksb" <ksb@discussions.microsoft.com> wrote in message news:18F6822E-6115-4E0C-B938...

How to trace slow message?
I have one user that is complaining about messages taking a significant amount of time(24 hrs) to deliver. The message all have legal attachments, which consists of several doc files adding up to under 2 MB worth of data (1.6 MB max). Our Exchange server has no restrictions set for e-mail attachments that I know of. I've been trying to test the situation out but can't duplicate the problem. There are two main message priginators that work in different companies(so different sending servers). My user has trouble receiving this e-mail from either sender. I've tried t...

Trace Flag Definitions
What do trace flags -t3601 / t3603 do and are there performance hits from using them? tbaze (tbaze@discussions.microsoft.com) writes: > What do trace flags -t3601 / t3603 do and are there performance hits from > using them? The situation you would use them is when SQL Server bombs on startup, because you have a number of processes that is not a power of 2. See http://blogs.msdn.com/sqlserverfaq/default.aspx?p=7. Generally, you should not use trace flags not documented in Books Online (and BOL has a very small number), unless you are adviced to by a support engineer, or...

TRACE problem
I am developping a project which will run for a long time before stop. And now there is sth odd happen: there is a runtime error occur after I run it for a day (some time is just for several hours). It has run for more than one day, it shouldn't be a loggic error, I think. I checked my code carefully, I don't see anything. Now, I put some TRACEs inside the code. The problem is there are too many TRACE messages, it exceeds that buffer of VC output window before application stop. I am thinking to save TRACE message into a file, do anybody know how to do that? Thanks. -- maggie ...

The TRACE macro
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vcrefCRuntimeClassIsDerivedFrom.asp?frame=true gives an example including the following code: > TRACE(_T("Creating object %s derived from %s, with object size %d > and schema %d\n"), pClass->m_lpszClassName, > pBaseClass->m_lpszClassName, pClass->m_nObjectSize, > pClass->m_wSchema); If this code is compiled in an ANSI environment then the _T macro will yield a multibyte string and the ANSI version of ATL::CTrace::s_trace.TraceV will be called. The %s format specifications wi...

How to implement TRACE
Hi there: I am developing with Platform SDK and IDE is VC++ 2005, I don't know how to ouput a string to the output window of IDE. In MFC we can use TRACE to do it, so how to make the same effects just use API? Thanks. >I am developing with Platform SDK and IDE is VC++ 2005, I don't know >how to ouput a string to the output window of IDE. In MFC we can use >TRACE to do it, so how to make the same effects just use API? OutputDebugString. Dave If you use "OutputDebugString" API, you can debug the app in release mode using "Dbgview.exe" this software i...

Trace common material in 2 sheets
I have sheet1 and sheet2 both sheets have same data but there are some new material # in sheet1. Problem is when apply Vlookup formula in sheet2 then quantities of new material numbers do not comes because these new materials numbers do not exist in sheet2. Is there any method? To trace new or diff. materials numbers those are exist in sheet1 Regards Zafar Not sure whether I have understood your query correctly. Try the below formula which will lookat Sheet1 and return whether the material # exists in Sheet1 or not...Reoplace the exist comment with your VLOOKUP...

PumpMessage trace in debug window
When debugging a C++ program in VS, I'm suddenly getting lots of "PumpMessage" messages in the debug winodw. How can I turn this off? How did I turn the PumpMessage tracing on in the first place? Brian Westcott wrote: > When debugging a C++ program in VS, I'm suddenly getting lots of > "PumpMessage" messages in the debug winodw. How can I turn this off? How did > I turn the PumpMessage tracing on in the first place? > > See 'MFC Tracer' on the Tools menu, or run the Tracer.exe application to change what is traced. -- Scott McPh...

Compare tables: Trace diff records
Hi, I have prepared a application for online test for employees. I have two diff tables. one is answer master and employee answers below is the answer master Answer no Option A Option B Option C Option D 1 FALSE FALSE TRUE FALSE 2 FALSE TRUE FALSE FALSE 3 TRUE FALSE FALSE FALSE 4 TRUE FALSE FALSE FALSE 5 FALSE TRUE FALSE FALSE 6 FALSE TRUE FALSE FALSE 7 FALSE FALSE FALSE TRUE 8 FALSE FALSE TRUE FALSE 9 FALSE TRUE FALSE FALSE Second is the emp answer Emp Emp Option A Emp Option B Emp Option C Emp ption D 1 FALSE TRUE FALSE FALSE 2 TRUE FALSE FALSE FALSE 3 FALSE TRUE FALSE FALSE 4 FALSE TRUE...

Audit Trace
How I can trace the HQ DB activites in row value changes on Table level. Regards niel ...

Exchange won't listen on 25
running exchange 2003; virtual server is set to all unassigned, port 25; run netstat-an nothing is on 25; telnet to port 25 from itself and the message "could not connect to host on port 25" comes up. help! please! thanks On Thu, 6 Jan 2005 13:01:19 -0700, "matthew kerner" <mkerner@viawest.net> wrote: >running exchange 2003; virtual server is set to all unassigned, port 25; run >netstat-an nothing is on 25; telnet to port 25 from itself and the message >"could not connect to host on port 25" comes up. >help! please! >thanks > >...

TRACE statements do not always print
Could someone tell me why some of my TRACE results do not always show up in my debug window? It should work as expected all the time. IOW, it should show up in debug window. Are you by any chance, looking at the release configuration? ---------- Ajay Kalra ajaykalra@yahoo.com Steve Russell wrote: > Could someone tell me why some of my TRACE results do not always show up in > my debug window? > Could someone tell me why some of my TRACE results do not always show up in > my debug window? > Here is one possible reason: http://support.microsoft.com/default.aspx?scid=kb;...

trace logins
How do I trace all logins to a specific database? I want all successful and failed accesses to some of my databases in my sql server. 1. I have about 100 databases, I want to trace accesses to about 20 of them. 2. The databases has several logins each, I don't want to search in logs for every single possible login name, which sometimes are AD groups/accounts (several thousand possible). 3. The databases is sometimes taken offline, the users gets an error - is this possible to trace/log this in any way? I don't mind if failed logins (wrong user/pass) also gets logged. ...

trace files
Does anyone know how to block trace files from comming in through Outlook or Internet explorer? Thanks, C- ...