Tag Archives: Logging

Enable SQL logging in Play 2.5+

Just a note to self on how to get (in my case) IntelliJ to spit out all SQL statements happening during unit tests.

  1. Add the following to application.conf
    db.default.logSql=true
  2. Add the following to logback.xml
    <logger name="org.jdbcdslog.ConnectionLogger" level="OFF"  />
    <logger name="org.jdbcdslog.StatementLogger"  level="INFO" />
    <logger name="org.jdbcdslog.ResultSetLogger"  level="OFF"  />

Source: StackOverflow

Enabling query logging on MariaDB/MySQL

When developing it can sometimes be very useful to see exactly what queries are sent to the database.

Found out there’s something called a General Query Log, and enabling it was really easy. Just add the following to your my.{ini,cnf} file:

[mysqld]
general-log=1
general-log-file=queries.log
log-output=file

Restart the server and you should now find the log in your data directory (unless no queries done yet).

If you don’t know where your data directory is, just run this query:

SHOW VARIABLES WHERE variable_name = 'datadir'