Solved

Options to log at the DB tier

Posted on 2011-02-22
5
233 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
It only partially answers my question
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
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.

Join & Write a Comment

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

763 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

14 Experts available now in Live!

Get 1:1 Help Now