• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

TraceSwitch

suityou01

Potty-trained
Joined
Jan 20, 2009
Messages
21,122
Likes received
773
Thanks received
222
Location
Clown World
I have a WPF C# app. I have a config file in the same folder as the exe

myapp.exe.config

I have a traceswitch defined thus

<configuration>
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="traceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
<remove name="Default" />
</listeners>
</trace>
<switches>
<add name="traceSwitch" value="4" />
</switches>
</system.diagnostics>
</configuration>

However, the little love won't pick up it's setting form the config file. :throw:

Any ideas what I am doing wrong? Driving me mental.

private static TraceSwitch traceSwitch = new TraceSwitch("traceSwitch", "My Trace Switch");
 
Looks okay to me. Are you sure you are compliling with debug or tracing on?
 
Just tried it (new WPF app with your config) and it worked fine.

EDIT: Can your code read anything (appSettings perhaps) from the config file?
 
Last edited: 13:33
I am an idiot. (We already knew this).

I flicked the folder listing into "Detailed" in explorer and saw

myApp.exe.config.txt

And wept.

:o
 
I am an idiot. (We already knew this).

I flicked the folder listing into "Detailed" in explorer and saw

myApp.exe.config.txt

And wept.

:o

Christ alive! This and databinding arrays.

:tired
 
Predicatable DP. I can get some MCP training on Notepad, you on the other hand will always be ugly. :D

HTH
Oh, so Microsoft operating systems are still associating files to applications based on the characters following the last period of the file name? How quaint.
 
Oh, so Microsoft operating systems are still associating files to applications based on the characters following the last period of the file name? How quaint.

Automagically. Wonderful isn't it?

I'm still a knob though. :D
 

Advertisers

Back
Top