Random Dev Notes

June 2, 2013

Identify Production Issues using VfpCommand Tracing

Filed under: .Net Development — Tags: — Tom Brothers @ 9:07 am

This blog entry show how to configure VfpClient to write trace information to a file and includes a couple example on how to identify issues.



Add the following diagnostics setting to have all VfpCommand command text written to a file.

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <configuration>
   3:    <system.diagnostics>
   4:      <sources>
   5:        <!-- Adding the VfpClient source will allow you to see all VFP commands in the Output panel. -->
   6:        <source name="VfpClient" switchValue="Information" >
   7:          <!-- This listener will trace VFP commands to a text file and is intended for use in production when troubleshooting an issue. -->
   8:          <listeners>
   9:            <add name="VfpClientTextWriterTraceListener"
  10:                 type="System.Diagnostics.TextWriterTraceListener"
  11:                 initializeData="c:\VfpClient.txt" />
  12:          </listeners>
  13:        </source>
  14:      </sources>
  15:      <!-- Need to include the following when using VfpClientTextWriterTraceListener -->
  16:      <trace autoflush="true"/>
  17:    </system.diagnostics>
  18:  </configuration>

* This diagnostics setting works for LINQ to VFP and the VFP Entity Framework Provider.

Find Performance Issues

Situation: A support ticket states that the application has become very slow.  (yep, a very vague ticket… surprised?)

Troubleshoot:  Review the log file looking for long running queries.  These can be identified by searching for the “Finished” details where the duration exceeds an acceptable time span.  Copy the sql statement from the log file and execute it in the VFP IDE to experiment with improving performance.


Find Errors

Situation:  A support ticket identifies an issue with the Customer search screen.  The user is searching for a Customer name that contains “d’a” which should result in two Customers but a “No Data Found” message is displayed instead.

Troubleshoot:  At this point all you really know is that there is a Customer query that isn’t returning the correct data.  So you could search the log for all Customer queries that include the search criteria specified in the support ticket.  In this example, it is clear that there was a problem with the query syntax as identified by the VfpException message.  However, if it wasn’t so obvious you could copy the sql statement from the log file and execute it in the VFP IDE to identify the problem.


Here is an example of what the problematic code could could look like.  (Sadly to say, I have seen this type of code in the production code)


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: