Skip to main content
Version: 2.0.x


Logging to a File at Compile-Time

To write compile-time queries to a log, use the -Dquill.log.file=queries.sql and specify the file to be written (e.g. queries.sql). The path is based on the build root (i.e. the current-working-directory of the Java build).

When using SBT, this parameter can be set either in your SBT_OPTS, the project-specific .sbtopts file or directly passed to the SBT command. In Intellij this can be set under settings -> sbt -> VM Parameters.

(Also make sure that use for: "Builds" is selected otherwise Intellij will not use SBT for the build in the first place.)

Screenshot from 2022-04-14 23-28-47

Also note that the -Dquill.macro.log.pretty=true parameter works together with -Dquill.log.file and will output pretty-printed queries to the specified file.

For a file that looks like this:

// Example.scala
package io.getquill

object Example {
case class Person(id: Int, name: String, age: Int)
case class Address(owner:Int, street: String)
val ctx = new SqlMirrorContext(PostgresDialect, Literal)
import ctx._

val people = run(query[Person])
val addresses = run(query[Person])

The following log will be produced:

-- file: /home/me/quill-example/src/main/scala/io/getquill/Example.scala:9:19
-- time: 2022-04-14T23:18:19.533

Person x


-- file: /home/me/quill-example/src/main/scala/io/getquill/Example.scala:10:22
-- time: 2022-04-14T23:18:19.9

Person x


Disable Compile-Time Console Logging

To disable the console logging of queries during compilation use quill.macro.log option:

sbt -Dquill.macro.log=false


Quill uses SLF4J for logging. Each context logs queries which are currently executed. It also logs the list of parameters that are bound into a prepared statement if any. To enable that use quill.binds.log option:

java -Dquill.binds.log=true -jar myapp.jar

Pretty Printing

Quill can pretty print compile-time produced queries by leveraging a great library produced by @vertical-blank which is compatible with both Scala and ScalaJS. To enable this feature use the quill.macro.log.pretty option:

sbt -Dquill.macro.log.pretty=true


[info] /home/me/project/src/main/scala/io/getquill/MySqlTestPerson.scala:20:18: SELECT,, p.age, a.ownerFk, a.street, a.state, FROM Person p INNER JOIN Address a ON a.ownerFk =


[info] /home/me/project/src/main/scala/io/getquill/MySqlTestPerson.scala:20:18:
[info] | SELECT
[info] |,
[info] |,
[info] | p.age,
[info] | a.ownerFk,
[info] | a.street,
[info] | a.state,
[info] |
[info] | FROM
[info] | Person p
[info] | INNER JOIN Address a ON a.ownerFk =