Printing messages to Oracle Trace or Alert Files

This tip can be very handy for someone trying to write debugging messages to Oracle Alert.log or trace file


It is so simple, it a built in procedure within DBMS_SYSTEM package.

The procedure you need to execute is  DBMS_SYSTEM.KSDIND(id, message)

where  id can be one of the following

1: Write to the standard trace file
2: Write to the alert log
3: Write to both files at once exec dbms_system.ksdwrt(3, '-- Start Message --');


another procedure called  DBMS_SYSTEM.SDIND(no) can be used just before exec DBMS_SYSTEM.KSDWRT.

no specify number of semi colons you want to print as indentation. It is executed before DBMS_SYSTEM.SKDWRT to help you identify your message with identation.

Range of valid values from 0 to 30.

exec dbms_system.ksdind(5);

will cause and ::::: just before the messages