--- layout: default_docs title: Chapter 12. Logging using java.util.logging header: Chapter 12. Logging using java.util.logging resource: media previoustitle: Data Sources and JNDI previous: jndi.html nexttitle: Further Reading next: reading.html --- **Table of Contents** * [Overview](logging.html#overview) * [Configuration](logging.html#configuration) * [Enable logging by using connection properties](logging.html#conprop) * [Enable logging by using logging.properties file](logging.html#fileprop) # Overview The PostgreSQL JDBC Driver supports the use of logging (or tracing) to help resolve issues with the PgJDBC Driver when is used in your application. The PgJDBC Driver uses the logging APIs of `java.util.logging` that is part of Java since JDK 1.4, which makes it a good choice for the driver since it don't add any external dependency for a logging framework. `java.util.logging` is a very rich and powerful tool, it's beyond the scope of this docs to explain or use it full potential, for that please refer to [Java Logging Overview](https://docs.oracle.com/javase/8/docs/technotes/guides/logging/overview.html). This logging support was added since version 42.0.0 of the PgJDBC Driver, and previous versions uses a custom mechanism to enable logging that it is replaced by the use of `java.util.logging` in current versions, the old mechanism is no longer available. Please note that while most people asked the use of a Logging Framework for a long time, this support is mainly to debug the driver itself and not for general sql query debug. # Configuration The Logging APIs offer both static and dynamic configuration control. Static control enables field service staff to set up a particular configuration and then re-launch the application with the new logging settings. Dynamic control allows for updates to the logging configuration within a currently running program. As part of the support of a logging framework in the PgJDBC Driver, there was a need to facilitate the enabling of the Logger using [connection properties](logging.html#conprop), which uses a static control to enable the tracing in the driver. Keep in mind that if you use an Application Server (Tomcat, JBoss, WildFly, etc.) you should use the facilities provided by them to enable the logging, as most Application Servers use dynamic configuration control which makes easy to enable/disable logging at runtime. The root logger used by the PgJDBC driver is `org.postgresql`. ## Enable logging by using connection properties The driver provides a facility to enable logging using connection properties, it's not as feature rich as using a `logging.properties` file, so it should be used when you are really debugging the driver. The properties are `loggerLevel` and `loggerFile`: **loggerLevel**: Logger level of the driver. Allowed values: `OFF`, `DEBUG` or `TRACE`. This option enable the `java.util.logging.Logger` Level of the driver based on the following mapping:
loggerLevel | java.util.logging |
---|---|
OFF | OFF |
DEBUG | FINE |
TRACE | FINEST |