Friday, August 15, 2008

Writing messages to the Oracle Alert Log

# If you want to test your alert log monitoring, or include application alerts in the database alert log.

1 - Write to trace file.
2 - Write to alertlog.
3 - Write to both.

exec dbms_system.ksdwrt(2, 'ORA-20000 test error message');

# or you can use utl_file

select
name into :alert_loc
from
v$parameter
where
name = 'background_dump_destination';

alter system set utl_file_dir = ':alert_log');

utl_file.fopen(':alert_loc','alertprod.log’,'W');

dbms_output.put_line('invalid_application_error');

utl_file.fclose(':alert_loc');