Oracle 5.0 Reference Manual page 1941

Table of Contents

Advertisement

...
</sources>
<switches>
<add name="MySwitch" value="Verbose"/>
...
</switches>
</system.diagnostics>
...
</configuration>
By default, trace information is written to the Output window of Microsoft Visual Studio. There are a
wide range of listeners that can be attached to the trace source, so that trace messages can be written
out to various destinations. You can also create custom listeners to allow trace messages to be written
to other destinations as mobile devices and web services. A commonly used example of a listener is
ConsoleTraceListener, which writes trace messages to the console.
To add a listener at runtime, use code such as the following:
ts.Listeners.Add(new ConsoleTraceListener());
Then, call methods on the trace source object to generate trace information. For example, the
TraceInformation(), TraceEvent(), or
The
TraceInformation()
TraceEvent()
value to be passed to indicate the trace message type, and also an application specific ID. The
TraceEventType
Using the
TraceData()
a message.
To ensure than these generated trace messages gets flushed from the trace source buffers to listeners,
invoke the
Flush()
The
Close()
resources, and closes the listeners associated with the trace source.
ts.TraceInformation("Informational message");
ts.TraceEvent(TraceEventType.Error, 3, "Optional error message");
ts.TraceData(TraceEventType.Error, 3, ex); // pass exception object
ts.Flush();
...
ts.Close();
20.2.5.14.1. Viewing MySQL Trace Information
This section describes how to set up your application to view MySQL trace information.
The first thing you need to do is create a suitable
shown in the following code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="mysql" switchName="SourceSwitch"
switchType="System.Diagnostics.SourceSwitch" >
<listeners>
<add name="console" />
<remove name ="Default" />
</listeners>
</source>
</sources>
<switches>
<!-- You can set the level at which tracing is to occur -->
<add name="SourceSwitch" value="Verbose" />
<!-- You can turn tracing off -->
Connector/Net Programming
method simply prints a string passed as a parameter. The
method, as well as the optional informational string, requires a
can have a value of Verbose, Information, Warning, Error, and Critical.
method you can pass any object, for example an exception object, instead of
method. When you are finished using a trace source, call the
method first calls Flush(), to ensure any remaining data is written out. It then frees up
methods can be used.
TraceData()
file for your application. An example is
app.config
1921
TraceEventType
method.
Close()

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents