Share |

Write a message to a trace file or the alert.log file

In case you want to write something to the Oracle alert.log file, you can use an undocumented package procedure to do so.

The dbms_system.ksdwrt package procedure takes 2 arguments, the first parameter is where you want to write the message, indicated by the second parameter to.
The first parameter can take 3 different values:
  • 1: Write the message to a trace file
  • 2: Write the message to the alert.log file
  • 3: Write the message to both a trace file and the alert.log file
For example, your application can write something to the alert.log file whenever a critical condition is encountered.
In order to write something to the alert.log, we need to provide 2 as the first parameter.
SQL> exec dbms_system.ksdwrt(2, '[YOURAPP] A Critical error was detected in module: INIT');

PL/SQL procedure successfully completed.
Now, if we check the alert.log file, we can see the message:
SQL> select value from v$parameter where name='background_dump_dest';

VALUE
--------------------------------------------------------------------------------
/u01/app/oracle/product/10.2.0/rdbms/log

SQL> select name from v$database;

NAME
---------------------------
ORA10G

SQL> host tail /u01/app/oracle/product/10.2.0/rdbms/log/alert_ORA10G.log
Mon Jun 15 21:57:47 2009
[YOURAPP] A Critical error was detected in module: INIT

Starting from Oracle 11g, you can query the X$DBGALERTEXT internal view to check the alert.log from within Oracle.
 Was this information helpful?  Yes No
If it was not helpful, please take some time to explain why. This is not to ask questions, you can do so in the forum.

Welcome to our forum for this Oracle tip Add your own message



At the moment there are no forum messages. You can add your own question.

Add your message

 Please provide your personal info 



 Please ask your message as briefly and clear as possible 

 Spam Protection 
Validation Code: e6ith5d040ahx27bv


Ask Your Question

If you need more information about this particular error message, you can leave a forum message.

We are replying to this message whenever we have some spare time, so please do not consider this as a private 'solve my critical issue asap' service.

Should you need professional Oracle Assistance to make your project a success, please have a look at our consultancy services.


Spam Protection

In order to prevent automatic generation of messages, we are asking for a validation code. This code is unique and is generated every time a new message is asked.

If you do not enter the validation correctly, your message will not be recorded.


Forum Rules

Please be polite, do not USE ALL UPPERCASE, no insults, violance or any other threats.