TraceOn Method for an Application

The TraceOn method turns on tracing for allocations and deallocations of Siebel objects and SQL statements that Siebel CRM creates. This method does not return any information.

Format

Application.TraceOn(filename, type, selection)

The following table describes the arguments for the TraceOn method.

Argument Description

filename

Output filename for trace messages. If you do not use this argument, then Siebel CRM logs tracing information to the Object Manager log file. More information about the filename argument is provided later in this topic.

type

The type of tracing to start. You can use the following values:

  • Allocation. Traces allocations and deallocations of Siebel objects. This feature is useful if you suspect a memory leak exists in your code.

  • SQL. Traces SQL statements that the Siebel application creates.

selection

Identifies the Siebel objects that Siebel CRM must trace for the Allocation trace type. This argument is "" if the trace type is SQL:

  • Script. Traces Siebel VB and Siebel eScript objects.

  • OLE. Traces allocations for data server or automation server programs.

  • All. Traces all objects that Siebel CRM creates as a result of scripting. This value does not trace Siebel objects that are defined through Siebel Tools.

Filename Argument of the TraceOn Method

You can use the following values for the filename argument:

  • $p. Substitutes the process Id for the filename.

  • $t. Substitutes the thread Id for the file name.

For example:

TheApplication().TraceOn("C:\\temp\\trace_$p_$t.txt", "Allocation", "All");

This code causes Siebel CRM to log trace files to the trace_1496_1412.txt file in the C:\temp\trace folder.

To make sure the filename argument is unique, you must place a separator between the $p and $t values. For example, assume you do not use a separator and the following items are true:

  • The process id for user A is 1 and the thread id is 12.

  • The process id for user B is 11 and the thread id is 2.

In this situation, the file name is trace_112.txt for user A and for user B, so Siebel CRM logs trace information for each user to the same file.

If you add a separator between the process id and the thread id, then the file names are unique and Siebel CRM logs trace information to a separate file for each user. For example:

  • trace_1_12.txt

  • trace_11_2.txt

Usage

To turn off tracing, you must call the TraceOff method. If you attempt to call the TraceOn method with a different filename without first calling TraceOff, then Siebel CRM writes trace information to the new trace file name. The old file remains open and is locked. You can issue multiple TraceOn statements to the same trace file.

It is recommended that you do not use the Trace method or the TraceOn method in a production environment. For more information, see Trace Method for an Application.

Used With

COM Data Control, COM Data Server, Siebel Java Data Bean, Mobile Web Client Automation Server, Server Script

Examples

The following example is for COM Data Server:

Private Sub TraceOn_Click()
   Dim ErrCode As Integer
   SiebelApplication.TraceOn "c:\temp\trace.txt", "allocation", 
      "all",       ErrCode
   If (ErrCode = 0) Then SiebelApplication.TraceOn
      "c:\temp\trace.txt",      "SQL", "",ErrCode   
   If (ErrCode = 0) Then SiebelApplication.Trace 
      "Start of Tracing!", 
      ErrCode
End Sub

The following example is in Siebel eScript:

function BusComp_PreSetFieldValue (FieldName, FieldValue)

{
TheApplication().TraceOn("C:\\temp\\trace.txt", "Allocation", "All");
TheApplication().TraceOn("C:\\temp\\trace.txt", "SQL", "");
TheApplication().Trace("start tracing!");

return (ContinueOperation);
}

The following example is in Siebel VB:

Sub Button2_Click
   TheApplication.TraceOn "C:\temp\trace.txt", "allocation",
      "all"
   TheApplication.TraceOn "C:\temp\trace.txt", "sql", ""
   TheApplication.Trace "start of tracing!"
End Sub

For example trace output, see Trace Method for an Application.

The following examples use Trace, Traceoff, and TraceOn methods to create a trace file with SQL statements issues by the scripting query.

The following example is in Siebel eScript:

function BusComp_NewRecord ()
{
   TheApplication().TraceOn("C:\\trace_output.txt", "SQL", "");
   TheApplication().Trace("Start of tracing!");
   var oBC = this.GetPicklistBusComp("Sales Stage");

   with (oBC)
   {
      SetViewMode(AllView);
      ClearToQuery();
      SetSortSpec("Sales Stage Order(ASCENDING)");
      ExecuteQuery(ForwardOnly);
      if (FirstRecord())
      {
         Pick();
      }
   }

   oBC = null;
   TheApplication().Trace("End of tracing!");
   TheApplication().TraceOff();
}

The following example is in Siebel VB:

Sub BusComp_NewRecord

   TheApplication.TraceOn "C:\trace_output.txt", "SQL", ""
   TheApplication.Trace "Start of tracing!"
   Dim oBC as BusComp
   Set oBC = Me.GetPicklistBusComp("Sales Stage")

   With oBC
      .SetViewMode AllView
      .ClearToQuery
      .SetSortSpec "Sales Stage Order(ASCENDING)"
      .ExecuteQuery ForwardOnly
      If .FirstRecord Then
         .Pick
      End If
   End With

   Set oBC = Nothing
   TheApplication.Trace "End of tracing!"
   TheApplication.TraceOff
End Sub

Related Topics

For more information, see the following topics: