PreviousData Provider for .NET Guide (9.1 revision 1) Next

Diagnostic Support

Show this topic in Library frames

The .NET Framework provides a Trace class that can help end users identify the problem without the program having to be recompiled.

The Pervasive.SQL data provider delivers additional diagnostic capability:

Tracing Method Calls

Developers can use the Trace class to help debug problems during development. You can use the properties and methods of the Trace class to help isolate problems and fix them without disturbing a running system.

The Pervasive.SQL data provider delivers additional tracing capability. The data provider traces the input arguments to all of its public method calls, as well as the outputs and returns from those methods (anything that a user could potentially call). Each call contains trace entries for entering and exiting the method. Provider-specific methods allow the data provider to trace all its method calls to a user-specified trace file.

Set the following environment variables to enable and control tracing:

Table 2-6 Environment Variables for Tracing
PVSW_Trace_File
Specifies the path and name of the trace file.
The initial default is \PVSW_NETTrace.txt.
PVSW_Recreate_Trace
When set to 1, recreates the trace file each time the application restarts.
The initial default value is 0. The trace file is appended.
If you change an environment variable value, you must restart the application for the new value to take effect.
PVSW_Enable_Trace
When set to 1 or higher, enables tracing.
The initial default value is 0. Tracing is disabled.

NOTE: SettingEnableTrace = 1 starts the tracing process. Therefore, you must define the property values for the trace file before setting EnableTrace. Once the trace processing starts, the values of TraceFile and RecreateTrace cannot be changed.

The following C# code fragment uses static methods in the Trace class to specify 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.

PsqlTrace.TraceFile="C:\\MyTrace.txt"; 
PsqlTrace.RecreateTrace = 1; 
PsqlTrace.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, and Value is the hash code of an object appropriate to the individual function calls.

During debugging, sensitive data can be read, even if it is stored as private or internal variable and access is limited to the same assembly. To maintain security, trace logs show passwords as five asterisks (*****).

PerfMon Support

The Performance Monitor utility in the Windows operating system allows you to record application parameters and review the results as a report or graph. You can also use Performance Monitor to identify the number and frequency of CLR exceptions in your applications.

The Pervasive.SQL data provider installs a set of PerfMon counters that let you tune and debug applications that use the data provider. The data provider's counters are located in the Performance Monitor under the category name Pervasive.SQL .NET Data Provider.

Table 2-7 describes the PerfMon counters that you can use to tune connections for your application.

Table 2-7 PerfMon Counters 
Counter
Description
Current # of Connection Pools
Current number of pools associated with the process.
Current # of Pooled Connections
Current number of connections in all pools associated with the process.
Current # of Pooled and Non-Pooled Connections
Current number of pooled and non-pooled connections.
Peak # of Pooled Connections
The highest number of connections in all connection pools since the process started.
Total # of Failed Connects
The total number of attempts to open a connection that have failed for any reason since the process started.
Total # of Failed Commands
The total number of command executions that have failed for any reason since the process started.

For information on using PerfMon and performance counters, refer to the Microsoft documentation library.


Chapter contents
Publication contents

Prev topic: Error Handling
Next topic: Using .NET Objects