Answers for "read oracle log file"

SQL
2

oracle log files

SELECT l.THREAD#, lf.GROUP#, lf.MEMBER,
       trunc(l.BYTES / 1e6) AS SIZE_MB,
       l.STATUS, l.ARCHIVED, lf.TYPE,
       lf.IS_RECOVERY_DEST_FILE AS RDF,
       l.SEQUENCE#, l.FIRST_CHANGE#,
       l.NEXT_CHANGE#
FROM V$LOGFILE lf JOIN V$LOG l ON l.GROUP# = lf.GROUP#
ORDER BY l.THREAD#, lf.GROUP#, lf.MEMBER;
Posted by: Guest on September-01-2021
0

log file oracle

CREATE OR REPLACE
PROCEDURE "WRITELOG" (LOGLEVEL IN VARCHAR2, LOGCONTEXT IN VARCHAR2, LOGMESSAGE IN VARCHAR2)
AUTHID CURRENT_USER
AS
    F1 UTL_FILE.FILE_TYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    LOG_DIR VARCHAR2;
    LOG_FILENAME VARCHAR2;
BEGIN
    LOG_DIR := 'MYLOG_DIR';
    LOG_FILENAME := 'mylog';
    F1 := UTL_FILE.FOPEN(LOG_DIR, TO_CHAR(SYSDATE,'YYYY-MM-DD') || '_' ||  LOG_FILENAME ||'.log','a');
    UTL_FILE.PUT_LINE(F1, TO_CHAR(SYSDATE,'DD-MM-YYYY HH:MI:SS AM') || ' - [' || LOGLEVEL || '] ' || LOGCONTEXT || ': ' || LOGMESSAGE);
    UTL_FILE.FCLOSE(F1);

EXCEPTION
    WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('ERROR: ' || TO_CHAR(SQLCODE) || SQLERRM);
      IF UTL_FILE.IS_OPEN(F1) THEN
        UTL_FILE.FCLOSE(F1);
      END IF;
END;
Posted by: Guest on April-06-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language