Appendix B. Additional Options for Oracle Database Logging
This appendix includes some logging alternatives available in Oracle Database.
The sys.dbms_system.ksdwrt Procedure
Developers often use the old but reliable sys.dbms_system.ksdwrt procedure to write to trace files, alert logs, or both. This procedure has been widely used, but unfortunately, it is not documented and even has a wrapped declaration:
sys.dbms_system.ksdwrt(destinbinary_integer,tstinvarchar2)
dest is one of the following:
-
Write to trace file
-
Write to alert log
-
Write to both
The dbms_adr and dbms_adr_app Packages
Using the dbms_adr and dbms_adr_app packages is another option. These packages contain procedures for creating alert messages and incidents in the Automatic Diagnostic Repository (ADR); note that alert.log is a part of ADR. Although these procedures are not documented, we can still read their declaration section with a short description in the package specification. Some of the procedures include write_trace, write_log, and create_incident.
The Error Stack
Finally, documented trace events can be used to dump an error stack of the current process, which can provide valuable information for debugging. A trace event is a diagnostic feature that allows you to gather additional information about the behavior of your code at runtime. To dump the error stack, you can execute the following command:
executeimmediateq'[ALTERSESSIONSETEVENTS'immediate trace name errorstack level 3' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access