Solved

Options to log at the DB tier

Posted on 2011-02-22
5
236 Views
Last Modified: 2012-05-11
Hi - We have an application which has a portion of its processing done in the database - the processing is done using PL/SQL and shell scripts and currently logging occurs by writing to a flat file - however we are looking to exert more control over the logging by setting logging levels and turning logging on and off dynamically at runtime.

Can anyone suggest options for DB tier level logging - the database we are using is Oracle 11g.

Thanks
0
Comment
Question by:abuyusuf
  • 4
5 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 34952736
If you are familiar with java and the log4j  framework,  there is a similar structure

log4plsql  you might want to explore


http://log4plsql.sourceforge.net/
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 34952761
another good option is the Instrumentation Library for Oracle, orginally from HOTSOS

http://sourceforge.net/projects/ilo/
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 34952803
and of course, you can always roll your own.

use autonomous_transactions to commit your logs independently of the transactions that spawned them (one of the few places autonomous transactions are appropriate to use)

Here is a simple logging procedure you expand on as needed
FUNCTION write_to_log (p_message VARCHAR2)
        RETURN NUMBER
    IS
/*
    Declaring with the Autonomous Transaction PRAGMA allows
    this procedure to commit and rollback independently of
    any parent transactions.

    i.e. The COMMIT in this procedure will only commit the
    insert statement of this procedure.  Actions outside of this
    procedure will not be committed or rolledback because of
    activity within this procedure.

    CREATE TABLE MY_LOG
    (
        LOG_TS    TIMESTAMP(6) WITH TIME ZONE,
        LOG_TEXT  VARCHAR2(4000 BYTE)
    )



*/
        PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
        INSERT INTO my_log
                    (log_ts, log_text
                    )
             VALUES (SYSTIMESTAMP, p_message
                    );

        COMMIT;
        RETURN 0;
    EXCEPTION
        WHEN OTHERS
        THEN
            ROLLBACK;
            RETURN SQLCODE;
    END write_to_log;

Open in new window

0
 

Author Closing Comment

by:abuyusuf
ID: 35324127
It only partially answers my question
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35324394
please rescore...you didn't ask for more information.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now