Log SQL that is communicated with the database

前端 未结 1 884
广开言路
广开言路 2021-01-16 09:21

I am working on a SQL Logger for my web application. I want to be able to Log the SQL query that is fired by user-interaction with the GUI. I\'m working in a Spring environm

1条回答
  •  无人共我
    2021-01-16 10:18

    i use jdbcdslog-exp for cases like this.

    add jdbcdslog-1.0.6.2.jar to classpath.

    add categories to log4j configuration (set INFO for ResultSetLogger too if you want - beware of OutOfMemory)

    
      
      
    
      
    
    

    if you need to switch statement logging by runtime you can start your log4j with

    PropertyConfigurator.configureAndWatch("log4j.xml", 60000);
    

    change your jdbc connection parameters (here example for hsql in jboss)

    from

    jdbc:hsqldb:hsql://localhost:1801
    org.hsqldb.jdbcDriver
    

    to

    jdbc:jdbcdslog:hsqldb:hsql://localhost:1801;targetDriver=org.hsqldb.jdbcDriver
    org.jdbcdslog.DriverLoggingProxy
    

    0 讨论(0)
提交回复
热议问题