Mattison (agnosticoracle) wrote in aspdotnet,
Mattison
agnosticoracle
aspdotnet

Tracing

I'm having some trouble with tracing. I have a static class whose method I call from a page that I'd like to get trace data from. The method looks like:
public sealed class DbUtils
{
static public int ExecuteNonQuery(string sql, string dsn)
{
  Trace.WriteLine("SQL", sql);
  int rowsAffected;

  OdbcConnection db     = new OdbcConnection(dsn);
  db.Open();
  OdbcCommand    cmd    = new OdbcCommand(sql, db);
  rowsAffected = cmd.ExecuteNonQuery();
  db.Close();
  return rowsAffected;
}
}
I've got trace="true" set on both the page I'm looking at and at the application (web.config). I get a lot of trace output at the bottom of the page or by looking at trace.axd, but I never see the information I'm trying to output in this function. Anyone know what I'm missing?

Update:
Apparently Page.Trace (from the aspx.cs page) and System.Diagnostics.Trace classes are different beasts. The proper way to make it work is to do this:
System.Web.HttpContext.Current.Trace.Write("SQL", sql);
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments