System.Diagnostics.Trace in referenced Class Library project

UtlraQita

New Member
I have a \[code\]Asp.Net\[/code\] (Web Api) project. In this project I reference another Class Library project.The traces that are written in the referenced Class Library don't show up in my Log.How can I make the traces off both projects show up in the same Log using \[code\]System.Diagnostics\[/code\]? In other words, how can I make the referenced Class Library use the \[code\]web.config\[/code\] Diagnostics settings from the Api Project? And if this isn't possible, how can I get the Traces that are written in the referenced Class Library in a Log at all?I tried to add the \[code\]System.Diagnostics\[/code\] settings from the \[code\]web.config\[/code\] to a \[code\]app.config\[/code\] but this doesn't seem to do anything at all.Api project:\[code\]TraceSource source = new TraceSource("MyProject");source.TraceEvent(TraceEventType.Information, 1, "My logged Trace");\[/code\]Referenced class library:\[code\]TraceSource source = new TraceSource("MyProject");source.TraceEvent(TraceEventType.Information, 1, "My disappearing Trace");\[/code\]Web.config\[code\]<system.diagnostics> <sources> <source name="MyProject" switchValue="http://stackoverflow.com/questions/15503200/All"> <listeners> <clear /> <add name="log" /> </listeners> </source> </sources> <sharedListeners> <add name="log" type="System.Diagnostics.XmlWriterTraceListener" initializeData="http://stackoverflow.com/questions/15503200/Log.svclog" /> </sharedListeners> <trace autoflush="true"/></system.diagnostics>\[/code\]
 
Back
Top