Solved

Options to log at the DB tier

Posted on 2011-02-22
5
240 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle DATE Column Space 11 80
Need a replacement data type in Oracle 6 78
Oracle SQL 6 60
Consolidating oracle query results to a single line 8 60
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

832 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