Advanced Server JDBC Connector Logging v42.2.19.1

Edit this page

The Advanced Server JDBC Connector supports the use of logging to help resolve issues with the JDBC Connector when used in your application. The JDBC Connector uses the logging APIs of java.util.logging that was part of Java since JDK 1.4. For information on java.util.logging, see The PostgreSQL JDBC Driver.

Note

Previous versions of the Advanced Server JDBC Connector used a custom mechanism to enable logging, which is now replaced by the use of java.util.logging in versions moving forward from community version 42.1.4.1. The older mechanism is no longer available.

Enabling Logging with Connection Properties (static)

You can directly configure logging within the connection properties of the JDBC Connector. The connection properties related to logging are loggerLevel and loggerFile.

loggerLevel

Logger level of the driver. Allowed values are OFF, DEBUG, or TRACE. This option enables the java.util.logging.Logger level of the driver to correspond to the following Advanced Server JDBC levels:

loggerLeveljava.util.logging
OFFOFF
DEBUGFINE
TRACEFINEST

loggerFile

File name output of the logger. The default is java.util.logging.ConsoleHandler. The following example sets the logging level to TRACE (FINEST) and the log file to EDB-JDBC.LOG:

jdbc:edb://myhost:5444/mydb?loggerLevel=TRACE&loggerFile=EDB-JDBC.LOG

Enabling Logging with logging.properties (dynamic)

You can use logging properties to configure the driver dynamically (for example, when using the JDBC Connector with an application server such as Tomcat, JBoss, WildFly, etc.), which makes it easier to enable/disable logging at runtime. The following example demonstrates configuring logging dynamically:

handlers = java.util.logging.FileHandler
//logging level
.level = OFF

The default file output is in the user’s home directory:

java.util.logging.FileHandler.pattern = %h/EDB-JDBC%u.log
java.util.logging.FileHandler.limit = 5000000
java.util.logging.FileHandler.count = 20
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.level = FINEST  java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n

Use the following command to set the logging level for the JDBC Connector to FINEST (maps to loggerLevel):

com.edb.level=FINEST

Then, execute the application with the logging configuration:

java –jar -Djava.util.logging.config.file=logging.properties run.jar