Traces into DLL
Traces into DLL
I have a referenced dll to my project with traces using the TraceSource and it´s not working. My code in the dll project is something like this:
private static readonly TraceSource ts = new TraceSource("DataSource");
...
ts.TraceInformation(string.Format("Info: 0", mess));
In the application project (where I import the DLL) the App.config:
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="MyListener" />
<remove name="Default" />
</listeners>
</trace>
<sources>
<source name="DataSource" switchValue="All">
<listeners>
<remove name="Default"/>
<add name="MyListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="MyListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\tempDefaultWriterOutput.log" />
</sharedListeners>
</system.diagnostics>
When I use a referenced project with the traces, all is working fine, but when I import the dll the trace is not working. Is there something wrong in the configuration?
Yes, the DLL reference in my application project. In the project properties->Build the Define TRACE Constant is checked but nothing changes
– Ernesto Rodriguez
Sep 14 '18 at 12:37
No trace output is happening. But if I reference to the project, the trace output is shown
– Ernesto Rodriguez
Sep 15 '18 at 10:46
1 Answer
1
I forgot that my DLL project is using a Nuget configuration (not Release). :( I set the TRACE constant in the project properties into Nuget configuration and it works.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
"import the dll" do you mean include as a reference in another project? either way, the TRACE flag must be set in the calling code. Is that the case? Do you define "not working" as a) no trace output happening or b) an exception?
– dlatikay
Sep 14 '18 at 12:25