How tracing works

Tracing is the process of writing status messages for routines to a file. Use tracing for debugging; tracing can generate a high volume of output, which is not appropriate for production databases. By default, tracing is disabled whenever you start a new database session.

Each tracing message has a tracing level associated with it. When you enable tracing, you set a threshold for tracing levels. Messages with a trace level less than or equal to the threshold are written to the trace file.

Tracing messages are written to a trace file, which is created with a default name and location, or with a name and location you specify. If you remove the trace file while tracing is enabled, it is automatically recreated. The default name and location of the trace file is tmp/session_id.trc, where session_id is the four-digit identifier of the current database server session. To obtain your current session ID, use the onstat -g ses command.

Messages are written to the trace file only if you:
Trace messages include the name of the executing routine, the source file name, and the line number of the call to Gen_Trace() with the embedded parameters %FUNCTION%, %FILENAME%, and %LINENO%. For example, the following example is a portion of a log file resulting from calling the enter routine and exit routine macros, DBDK_TRACE_ENTER() and DBDK_TRACE_EXIT(), for the Distance() function:
=========================================
Tracing session: 12 on 3/4/1998

10:55:32 Entering function Distance (Circle.c)

10:55:32 Successfully exiting Distance (Circle.c)
Important: If you want to include parameters other than %FUNCTION%, %FILENAME%, and %LINENO% in a message, you must call the gl_dprintf() function for trace messages or the mi_db_error_raise() function for error messages. For an example of calling these functions, see the Gen_Trace() function in the generated source code. See the Informix® DataBlade API Programmer's Guide for more information about using these functions.