Search code examples
sql-serverwebsphere-libertymssql-jdbcopen-liberty

How to log/trace mssql jdbc driver from java?


I would like to log all actions(especially the connectivity related ones) from my mssql-jdbc driver.

I tried to follow these instructions, but without luck.

I tried to create a new logger.properties file on my desktop

included -Djava.util.logging.config.file=C:\Users\myUser\Desktop\logging.properties in my jvm.options file.

Put these parameters in the logging.properties file

handlers = java.util.logging.FileHandler
.level = OFF
java.util.logging.FileHandler.pattern= %h/java%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
com.microsoft.sqlserver.jdbc.level = FINEST

From here i was under the impression it would log all jdbc activities to a .log file in my userhome directory. But it doesn't.

What am I doing wrong here? Or are there any other ways to log jdbc activity?


Solution

  • According to the following WebSphere Liberty knowledge center document you can configure java.util.logging for the Microsoft SQL Server JDBC driver in bootstrap.properties as follows,

    com.ibm.ws.logging.trace.specification=*=audit=enabled:com.microsoft.sqlserver.jdbc=FINE
    

    The output will end up in the WebSphere liberty trace logs, which have a default location of [liberty-server-location]/logs/trace.log