The log engine, it’s a mechanism that presents a large variety of solutions.
Every project, software or company have a different way of register the actions of their processes.
Whenever a new version of Oracle is released, one of my concerns is trying to improve my own logging engine with the new features.
But let’s by stages, my log engine is based in the following objects:
- 3 tables :”APPL_LOG”, “SYS_LOG” and “APPL_LOG_TYPE”
- 1 package :”PKG_APPL_LOG”
- 2 sequences:”SEQ_LOG_ID” and “SEQ_SYS_LOG_ID”
- 4 triggers :”TR_APPL_LOG_INS”,”TR_APPL_LOG_UPD”, “TR_SYS_LOG_INS” and “TR_SYS_LOG_UPD”
- Table “APPL_LOG”
The purpose of this table is to register all process/applications actions. As this table will be increase a lot, i decided to partition by date and sub-partition by type of error.CREATE TABLE APPL_LOG (LOG_ID NUMBER, LOG_DATE TIMESTAMP, SEQ_ID NUMBER, TYPE_ID NUMBER, APPLICATION VARCHAR2(256), OBJECT VARCHAR2(32), MESSAGE VARCHAR2(256), CREATED_USER VARCHAR2(64), CREATED_DATE TIMESTAMP, MODIFIED_DATE TIMESTAMP, MODIFIED_USER VARCHAR2(64) ) PARTITION BY RANGE(LOG_DATE) SUBPARTITION BY LIST (TYPE_ID) SUBPARTITION TEMPLATE( SUBPARTITION critical VALUES (1) TABLESPACE TBS1, SUBPARTITION error1 VALUES (2) TABLESPACE TBS2, SUBPARTITION warning VALUES (3) TABLESPACE TBS3, SUBPARTITION information VALUES (4) TABLESPACE TBS4, SUBPARTITION monitor VALUES (5) TABLESPACE TBS5, SUBPARTITION debugging VALUES (6) TABLESPACE TBS6 ) ( PARTITION p_08052011 VALUES LESS THAN (TO_DATE('09/05/2011','DD/MM/YYYY')), PARTITION p_09052011 VALUES LESS THAN (TO_DATE('10/05/2011','DD/MM/YYYY')), PARTITION p_10052011 VALUES LESS THAN (TO_DATE('11/05/2011','DD/MM/YYYY')) ); ALTER TABLE APPL_LOG ADD CONSTRAINT PK_APPL_LOG_ID PRIMARY KEY (LOG_ID);
Below there are listed the possible types of error:
- Critical
- Error
- Warning
- Information
- Monitoring
- Debug