SQL Guide : Diagnostics and troubleshooting for SQL : Tracing facilities for stored procedures and triggers : User-definable trace output from procedure code
  
User-definable trace output from procedure code
From inside your stored procedure or trigger, you can send “trace” output to the soltrace.out file by using the following command:
WRITETRACE (entry VARCHAR)
You can turn the output on or off by using the command:
ADMIN COMMAND 'usertrace { on | off }
user username { procedure | trigger | table } entity_name'
The entity_name is the name of the procedure, trigger, or table for which you want to turn tracing on or off. If the keyword “table” is specified, then all triggers on that table are traced.
You may turn on (or off) tracing for a specified procedure, a specified trigger, or for all triggers on a specified table.
Trace is activated only when the specified user calls the procedure / trigger. This is useful, for example, when tracing propagated procedure calls in a advanced replication master.
Turning on tracing turns it on in all procedure/trigger calls by this user, not just calls from the connection that switched the trace on. If you have multiple connections that use the same username, then all of the calls in all of those connections will be traced. Furthermore, the tracing will be done on calls propagated to (executed on) the master, as well as the calls executed on the replica.
See also
Tracing facilities for stored procedures and triggers