LOG4PLSQL: User Guide
Author: Guillaume Moulard |
LOG4PLSQL is a PLSQL framework
for logging in all PLSQL code
ú
Package,
ú
Procedure,
ú
Function,
ú
Trigger,
ú
PL/SQL Web application.
ú
Oracle Tools (Form, report,…)
Purpose:
ú
Easy of implemented and use
ú
Possibility to log apart from transaction
ú
Possibility to adapt the level of logging
depending on user requirements
ú
Ability to use all LOG4J feature.
ú
Provide a complet set of tools PL/SQL
developpement (bebug variable, SQLERRM, assert, call stack, ... ).
Log destination:
ú
Table in Oracle Datablase
ú
Oracle Datablase alert.log file
ú
Oracle Datablase trace file
ú
Standard output
ú
By log4J::Log4JbackgroundProcess:
o Async,
o JDBC,
o JMS,
o NTEventLog,
o SMTP,
o Socket,
o SocketHub,
o Syslog,
o Telnet,
o Writer
Log4plsql was born from the log4J spirit (and use it).
See : Log4j documentation : http://logging.apache.org/log4j/docs/documentation.html
and the book write
by

|
|
1. Download zip file in project page : http://log4plsql.sourceforge.net/ 2. unzip Log4plsql.zip (see: http://www.info-zip.org for zip tools) |
||||||||||||
|
|
3. Edit Log4plsql\cmd\setVariable.bat or
Log4plsql/cmd/setVariable.sh file
|
||||||||||||
|
|
4. Run install.bat or install.sh in cmd
directory Perhaps is necessary to change to exec
attribute this commande : chmod +x *.sh If you have some SP2-0310 error for
param.sql or return.sql, ignore it, or create 2 empty file in /sql/.
(param.sql and return.sql) |
||||||||||||
|
|
If you don’t use LOG4J features your
installation is completed. Next step is required if you use a LOG4J
function |
||||||||||||
|
|
5. Edit .\properties\log4plsql.xml
|
||||||||||||
|
|
6. Start startLog4JbackgroundProcess.bat in cmd directory |
|
|
PL/SQL Code |
Constant |
Value |
Description |
|
|
|
LOFF |
1 |
The OFF has the highest possible rank and is intended to turn off
logging. |
|
|
plog.fatal('Text'); |
LFATAL |
2 |
The FATAL level designates very severe error events that will
presumably lead the application to abort |
|
|
plog.error('Text'); |
LERROR |
3 |
The ERROR level designates error events that might still allow the
application to continue running. |
|
|
plog.warn('Text'); |
LWARN |
4 |
The WARN level designates potentially harmful situations |
|
|
plog.info('Text'); |
LINFO |
5 |
The INFO level designates informational messages that highlight the
progress of the application at coarse-grained level. |
|
|
plog.debug('Text'); |
LDEBUG |
6 |
The DEBUG Level designates fine-grained informational events that are
most useful to debug an application. |
|
|
|
LALL |
7 |
The ALL has the lowest possible rank and is intended to turn on all
logging. |
By default Log4PLSQL log in database table name TLOG:
|
|
SQL> desc ULOG.TLOG Nom
NULL ? Type -----------------------------------------
-------- ---------------------------- ID NOT
NULL NUMBER LDATE
DATE LLEVEL NUMBER LSECTION VARCHAR2(2000) LTEXTE VARCHAR2(2000) LUSER VARCHAR2(30) LHSECS
NUMBER SQL> |
To read this table you can select in the TLOG table or
in the VLOG view.
It is possible to log to alert.log, and trace file and
to view directly the log output in standard output. (see paragraph: Advanced
features for developer)
If you want to log in other destination, it is
necessary to use a Log4JbackgroundProcess feature. Currently, some log4j
appenders exist for the console,
files,
GUI components, remote
socket servers, JMS,
NT
Event Loggers, and remote UNIX Syslog
daemons. It is also possible to log asynchronously.
2003-06-07
01:39:27,878 INFO
(backgroundProcess) - Start []
2003-06-07
01:39:27,888 DEBUG (backgroundProcess) - log4plsql.properties :
.\properties\log4plsql.xml []
2003-06-07
01:39:27,888 DEBUG (backgroundProcess) - log4j.properties :
.\\properties\\log4j.properties []
2003-06-07
01:39:27,898 DEBUG (ReaderDBThread) - ReaderLogDataBase : Connect []
2003-06-07 01:39:29,481
DEBUG (ReaderDBThread) - begin loop []
2003-06-07
01:39:38,784 DEBUG (log4plsql.SCOTT.block.codePart1) - message for debug
[DatabaseLoginDate:07 juin 2003 01:39:38:
30]
2003-06-07
01:39:38,834 INFO
(log4plsql.SCOTT.block.codePart1) - message for information
[DatabaseLoginDate:07 juin 2003 01:39:38:
30]
2003-06-07
01:39:38,874 WARN
(log4plsql.SCOTT.block.codePart1) - message for warning [DatabaseLoginDate:07 juin 2003 01:39:38:
31]
2003-06-07
01:39:38,924 ERROR (log4plsql.SCOTT.block.codePart1) - message for error
[DatabaseLoginDate:07 juin 2003 01:39:38:
31]
2003-06-07
01:39:38,954 FATAL (log4plsql.SCOTT.block.codePart1) - message for fatal
[DatabaseLoginDate:07 juin 2003 01:39:38:
31]

After installation it is possible to create in your
database a simple procedure: