skip to main content
Developing ADO.NET Applications : Diagnostic Support : Tracing Method Calls : Using Static Methods
 

Using Static Methods

Some users may find that using static methods on the .NET Client’s Trace class to be a more convenient way to enable tracing. The following C# code fragment uses static methods on the .NET Trace object to create an OpenAccessTrace class with a trace file named MyTrace.txt. The values set override the values set in the environmental variables. All subsequent calls to the data provider will be traced to MyTrace.txt.
OpenAccessTrace.TraceFile="C:\\MyTrace.txt";
OpenAccessTrace.RecreateTrace = 1;
OpenAccessTrace.EnableTrace = 1;
The trace output has the following format:
<Correlation#> <Timestamp> <CurrentThreadName>
<Object Address> <ObjectName.MethodName> ENTER (or EXIT)
Argument #1 : <Argument#1 Value>
Argument #2 : <Argument#2 Value>
...
RETURN: <Method ReturnValue> // This line only exists for EXIT
where:
Correlation# is a unique number that can be used to match up ENTER and EXIT entries for the same method call in an application.
Value is the hash code of an object appropriate to the individual function calls.