JDBC Logging
JDBC Logging#
JDBC Logging means to record all sorts of logs occurring in the Altibase JDBC driver, and the log can be recorded by using java.util.logging package. This section will discuss how to use and configure the JDBC logging.
Installing JDBC Logging#
In order to record a log from the JDBC driver, the JDBC jar file with an added logging function should be used. Also, it should be used after activating a logging function in the ALTIBASE_JDBC_TRACE environment variable.
JRE Version#
JRE 1.5 or above must be installed in order to execute the JDBC logging and other library is not necessary.
Setting the CLASSPATH#
To use the JDBC Logging, Altibase_t.jar file must be added to the CLASSPATH environment variable.
ex) When using the bash shell in the Unix environment
export CLASSPATH=$ALTIBASE_HOME/lib/Altibase_t.jar:.:$CLASSPATH
Activating Logging#
Global logging is activated without modifying a program by altering the ALTIBASE_JDBC_TRACE environment variables with JVM parameters. However, a client program should be re-started in order to apply the modified values of the ALTIBASE_JDBC_TRACE.
java -DALTIBASE_JDBC_TRACE=true ...
Instruction on JDBC Logging#
Setting java.util.logging file#
Setting java.util.logging can be executed in $JRE_HOME/lib/logging.properties or it can be separately configured on java.util.logging.config.file as follows.
java -Djava.util.logging.config.file=$ALTIBASE_HOME/sample/JDBC/Logging/logging.properties -DALTIBASE_JDBC_TRACE=true ...
Altibase provides a logging.properties sample file in a directory of $ALTIBASE_HOME/sample/JDBC/Logging, and by using or referencing it the user can directly create a configuring file and use it Djava.util.logging.config.file property.
Logger Types#
A Logger is constructed with a tree structure and it is used to partially adjust setting or the amount of logs. The logger types supported by Altibase JDBC driver are as follows.
Logger | Description |
---|---|
altibase.jdbc | Altibase JDBC messages(JDBC API call, such as connection, statement, prepared statement, etc.) |
altibase.jdbc.pool | Messages regarding the connection pool |
altibase.jdbc.rowset | ResultSet message |
altibase.jdbc.xa | xa messages |
altibase.jdbc.failover | failover messages |
altibase.jdbc.cm | CmChannel network packet messages |
Logger Levels#
If a logger level is specified, the amount of logs can be concretely adjusted. The following table explicates the provided levels by Altibase JDBC driver, and the logs are left in detail more and more as it goes to FINEST from SEVER. If the CONFIG level is specified, logs of SEVERE, WARNING, INFO, CONFIG levels are left.
Logger level | Description |
---|---|
OFF | Off is not record the log |
SEVERE | SQLException or when an inner error occurred, the relevant logs are recorded in the SEVERE level. |
WARNING | SQLWarning is left the log in the WARNING level. |
INFO | The JDBC driver internally logs by monitoring specific objects. |
CONFIG | This level is usually used to check what kind of a SQL statement is internally executed in the JDBC driver. In terms of the PreparedStatement, sql is displayed when preparing; however, in terms of a statement, the sql is displayed with milli sec unit when it is being executed. |
FINE | This level leaves argument values and return values in the log when entering to the standard JDBC API. The amount of logs can be large since logs are left when entering to the API, and the time which is taken for connection or statement to close is additionally displayed. |
FINEST | In the FINEST level, the packet information exchanged between JDBC driver and Altibase server is logged. It is the largest amount of logs. |
logging.properties#
The following is a logging.properties sample which leaves network packet logs with the log level of CONFIG. More information can be found in $ALTIBASE_HOME/sample/JDBC/Logging/logging.properties as well. .
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler --> FileHandler and ConsoleHandler
added as basic handlers.
.level = CONFIG # The root logger should be specified with the CONFIG.
# This is a section in which configuring the default setting of java.util.logging.FileHandler.
# The level of FileHandler is specified with CONFIG since only the sql information is needed.
# default file output is in same directory.
java.util.logging.FileHandler.level = CONFIG
java.util.logging.FileHandler.pattern = ./jdbc_trace.log
java.util.logging.FileHandler.limit = 10000000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.append = false
java.util.logging.FileHandler.formatter = Altibase.jdbc.driver.logging.SingleLineFormatter
# This is a section configuring java.util.logging.ConsoleHandler.
# SingleLineFormatter is used to print out logs in a line.
java.util.logging.ConsoleHandler.level = CONFIG
java.util.logging.ConsoleHandler.formatter = Altibase.jdbc.driver.logging.SingleLineFormatter
# This is a section in which altibase jdbc logger is configured,
# and the rowset level is specified with SEVERE since the record set information needs to be excluded.
# The Network packet information should be loged;
# thus, the cm level is specified with FINEST.
# Moreover, in terms of the network packet,
# MultipleFileHandler was used as a handler in order to store a file per each session.
altibase.jdbc.level = CONFIG
altibase.jdbc.rowset.level = SEVERE
altibase.jdbc.cm.level = FINEST
altibase.jdbc.cm.handlers = Altibase.jdbc.driver.logging.MultipleFileHandler
#altibase.jdbc.cm.handlers = java.util.logging.FileHandler
# By using jdbc_net_%s.log,
# it is configured that a file will be created per a session ID.
# Also, a log will be created in a XML formatter file by using XMLFormatter.
Altibase.jdbc.driver.logging.MultipleFileHandler.level = FINEST
Altibase.jdbc.driver.logging.MultipleFileHandler.pattern = ./jdbc_net_%s.log
Altibase.jdbc.driver.logging.MultipleFileHandler.limit = 10000000
Altibase.jdbc.driver.logging.MultipleFileHandler.count = 1
Altibase.jdbc.driver.logging.MultipleFileHandler.formatter = java.util.logging.XMLFormatter