How to enable trace/debugging output with Anorm on Play 2.4.0

后端 未结 2 1945
南方客
南方客 2021-01-14 03:52

With Play 2.4.0 Anorm got moved to an external package and logging got changed to LogBack (http://logback.qos.ch)

All well and good but nowhere are the class/package

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 04:30

    Anorm doesn't log anything (and doesn't use logback), but 'output' is plain JDBC, so you can configure debug on your connection pool.

    EDIT:

    The debug utility from my framework Acolyte can be used to print/log the JDBC statement that would have been executed with the connection.

    If you have SQL"SELECT * FROM Test WHERE id = $id", you can debug it as following.

    
    
    import acolyte.jdbc.AcolyteDSL
    
    AcolyteDSL.debuging() { implicit dcon =>
      SQL"SELECT * FROM Test WHERE id = $id"
      // just print the prepared statement
      // with parameters bound
    }
    
    // really execute,
    // the check the real ResultSet
    SQL"SELECT * FROM Test WHERE id = $id"
    

    Acolyte is available on Maven Central.

提交回复
热议问题