By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Trace Listener

P: n/a
Hi all,

can anyone help me with some tracing I am trying to do
in my application. I have a configuration file containing
the XML as detailed below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<switches>
<add name="myBooleanSwitch" value="2" />
</switches>
</system.diagnostics>
</configuration>

I have declared a public variable as detailed below:

Public myBooleanSwitch As New BooleanSwitch("myBooleanSwitch",
"Controlss Data Tracing")
However, when I execute the code below, I only appear to insert
the unconditional trace.writeline command, and not the conditional
trace.writelineif command.
Dim myLog As New FileStream("C:\output.txt",
FileMode.OpenOrCreate)
Dim myTrace As New TextWriterTraceListener(myLog)
Trace.Listeners.Add(myTrace)
Trace.AutoFlush = True
Trace.WriteLineIf(myBooleanSwitch.Enabled, "Boolean Switch
Enabled")
Trace.WriteLine("Trace write line")
'Trace.Flush()
Trace.Close()
myLog.Close()
Trace.Listeners.Remove(myTrace)
myTrace.Dispose()
myLog = Nothing
Does anyone have any ideas? I created the configuration file,
called Debug_Trace Listener.config using the IDE (VB.Net). I
have even copied it to the bin folder and the debug folder to make
sure there it can be found.

Many thanks,

Jason.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Is this a Windows Forms Application? If so rename the config file to
"App.config" and it should work.

The config file should be in the root source folder of the project if
running from the IDE, or in the folder of the compiled application
otherwise.

Hope this helps.
"Jason L James" <ja***@no-spam.dive-master.org> wrote in message
news:41***************@news.demon.co.uk...
Hi all,

can anyone help me with some tracing I am trying to do
in my application. I have a configuration file containing
the XML as detailed below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<switches>
<add name="myBooleanSwitch" value="2" />
</switches>
</system.diagnostics>
</configuration>

I have declared a public variable as detailed below:

Public myBooleanSwitch As New BooleanSwitch("myBooleanSwitch",
"Controlss Data Tracing")
However, when I execute the code below, I only appear to insert
the unconditional trace.writeline command, and not the conditional
trace.writelineif command.
Dim myLog As New FileStream("C:\output.txt",
FileMode.OpenOrCreate)
Dim myTrace As New TextWriterTraceListener(myLog)
Trace.Listeners.Add(myTrace)
Trace.AutoFlush = True
Trace.WriteLineIf(myBooleanSwitch.Enabled, "Boolean Switch
Enabled")
Trace.WriteLine("Trace write line")
'Trace.Flush()
Trace.Close()
myLog.Close()
Trace.Listeners.Remove(myTrace)
myTrace.Dispose()
myLog = Nothing
Does anyone have any ideas? I created the configuration file,
called Debug_Trace Listener.config using the IDE (VB.Net). I
have even copied it to the bin folder and the debug folder to make
sure there it can be found.

Many thanks,

Jason.

Nov 21 '05 #2

P: n/a
Matt,

that work just fine.

Many thanks,

Jason.

On Wed, 25 Aug 2004 15:43:20 +0100, "Matt S"
<ma**@toomuchspamalready.com> wrote:
Is this a Windows Forms Application? If so rename the config file to
"App.config" and it should work.

The config file should be in the root source folder of the project if
running from the IDE, or in the folder of the compiled application
otherwise.

Hope this helps.
"Jason L James" <ja***@no-spam.dive-master.org> wrote in message
news:41***************@news.demon.co.uk...
Hi all,

can anyone help me with some tracing I am trying to do
in my application. I have a configuration file containing
the XML as detailed below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<switches>
<add name="myBooleanSwitch" value="2" />
</switches>
</system.diagnostics>
</configuration>

I have declared a public variable as detailed below:

Public myBooleanSwitch As New BooleanSwitch("myBooleanSwitch",
"Controlss Data Tracing")
However, when I execute the code below, I only appear to insert
the unconditional trace.writeline command, and not the conditional
trace.writelineif command.
Dim myLog As New FileStream("C:\output.txt",
FileMode.OpenOrCreate)
Dim myTrace As New TextWriterTraceListener(myLog)
Trace.Listeners.Add(myTrace)
Trace.AutoFlush = True
Trace.WriteLineIf(myBooleanSwitch.Enabled, "Boolean Switch
Enabled")
Trace.WriteLine("Trace write line")
'Trace.Flush()
Trace.Close()
myLog.Close()
Trace.Listeners.Remove(myTrace)
myTrace.Dispose()
myLog = Nothing
Does anyone have any ideas? I created the configuration file,
called Debug_Trace Listener.config using the IDE (VB.Net). I
have even copied it to the bin folder and the debug folder to make
sure there it can be found.

Many thanks,

Jason.



Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.