17

Slick fills up the console with a massive amount of log messages. I wanted, like the documentation suggested, to use slf4j-nop, so logging is turned off, but Akka needs its own slf4j library.

So I'm left with akka-slf4j_2.10 that Slick also uses. I've tried many things. Included in my application.conf is this (tried with and without "):

logger="OFF"
logger.scala.slick="OFF"
logger.scala.slick.session="OFF"
logger.scala.slick.jdbc.JdbcBackend.statement="OFF"
logger.scala.slick.jdbc="OFF"

It has zero effect. Can someone help me turn this logging off so I can once again like Slick?

Edit

Some of the log messages I get:

17:16:56.706 [seating-akka.actor.default-dispatcher-8] DEBUG scala.slick.ast.Node$ - Assigned type Int/INTEGER to node InsertColumn SEAT_ID

17:16:56.710 [seating-akka.actor.default-dispatcher-8] DEBUG scala.slick.compiler.QueryCompiler - After phase insertCompiler:
Community
  • 1
  • 1
Arthur C
  • 1,274
  • 1
  • 14
  • 34

4 Answers4

29

I've fixed it by adding a logback.xml to src/main/resources:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <logger name="scala.slick" level="INFO" />
</configuration>

I found this somewhere in a Github project.

raam86
  • 6,785
  • 2
  • 31
  • 46
Arthur C
  • 1,274
  • 1
  • 14
  • 34
  • 2
    For general reference. In the example above, what really controls the level of logging for slick specifically is the line `` that sets the level for logging for Slick specifically. Slick will always produce a bunch of QueryCompiler* messages whenever slick logging (inherited or specifically set) is set to DEBUG. In your original post, it shows that the root/base logging level was set to DEBUG, thus Slick logback has inherited this and putting out a bunch of QueryCompiler messages for the _runtime_ compilation of queries (some could be pre-compilable) – neurozen Mar 27 '15 at 03:28
  • 7
    Confirmed it works. Use `` if you are using Slick 3.0.0+ – Jimmy Au May 31 '15 at 04:44
  • 2
    I'm on slick 3.2.0 and nothing here has worked. Am I doomed to incredibly noisy build logs? – CPS Aug 03 '17 at 12:51
2

The logback.xml file given here solved my problem.

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>*** \(%logger{30}\)%green(%X{debugId}) %msg%n</pattern>
        </encoder>
    </appender>
    <root level="${log.root:-info}">
        <appender-ref ref="STDOUT" />
    </root>
    <logger name="slick.basic.BasicBackend.action"          level="${log.action:-info}" />
    <logger name="slick.basic.BasicBackend.stream"          level="${log.stream:-info}" />
    <logger name="slick.compiler"                           level="${log.qcomp:-info}" />
    <logger name="slick.compiler.QueryCompiler"             level="${log.qcomp.phases:-inherited}" />
    <logger name="slick.compiler.QueryCompilerBenchmark"    level="${log.qcomp.bench:-inherited}" />
    <logger name="slick.compiler.Inline"                    level="${log.qcomp.inline:-inherited}" />
    <logger name="slick.compiler.AssignUniqueSymbols"       level="${log.qcomp.assignUniqueSymbols:-inherited}" />
    <logger name="slick.compiler.InferTypes"                level="${log.qcomp.inferTypes:-inherited}" />
    <logger name="slick.compiler.ExpandTables"              level="${log.qcomp.expandTables:-inherited}" />
    <logger name="slick.compiler.EmulateOuterJoins"         level="${log.qcomp.emulateOuterJoins:-inherited}" />
    <logger name="slick.compiler.ForceOuterBinds"           level="${log.qcomp.forceOuterBinds:-inherited}" />
    <logger name="slick.compiler.RemoveMappedTypes"         level="${log.qcomp.removeMappedTypes:-inherited}" />
    <logger name="slick.compiler.CreateResultSetMapping"    level="${log.qcomp.createResultSetMapping:-inherited}" />
    <logger name="slick.compiler.ExpandSums"                level="${log.qcomp.expandSums:-inherited}" />
    <logger name="slick.compiler.ExpandRecords"             level="${log.qcomp.expandRecords:-inherited}" />
    <logger name="slick.compiler.ExpandConditionals"        level="${log.qcomp.expandConditionals:-inherited}" />
    <logger name="slick.compiler.FlattenProjections"        level="${log.qcomp.flattenProjections:-inherited}" />
    <logger name="slick.compiler.CreateAggregates"          level="${log.qcomp.createAggregates:-inherited}" />
    <logger name="slick.compiler.RewriteJoins"              level="${log.qcomp.rewriteJoins:-inherited}" />
    <logger name="slick.compiler.RemoveTakeDrop"            level="${log.qcomp.removeTakeDrop:-inherited}" />
    <logger name="slick.compiler.ResolveZipJoins"           level="${log.qcomp.resolveZipJoins:-inherited}" />
    <logger name="slick.compiler.HoistClientOps"            level="${log.qcomp.hoistClientOps:-inherited}" />
    <logger name="slick.compiler.ReorderOperations"         level="${log.qcomp.reorderOperations:-inherited}" />
    <logger name="slick.compiler.MergeToComprehensions"     level="${log.qcomp.mergeToComprehensions:-inherited}" />
    <logger name="slick.compiler.OptimizeScalar"            level="${log.qcomp.optimizeScalar:-inherited}" />
    <logger name="slick.compiler.FixRowNumberOrdering"      level="${log.qcomp.fixRowNumberOrdering:-inherited}" />
    <logger name="slick.compiler.PruneProjections"          level="${log.qcomp.pruneProjections:-inherited}" />
    <logger name="slick.compiler.RewriteDistinct"           level="${log.qcomp.rewriteDistinct:-inherited}" />
    <logger name="slick.compiler.RewriteBooleans"           level="${log.qcomp.rewriteBooleans:-inherited}" />
    <logger name="slick.compiler.SpecializeParameters"      level="${log.qcomp.specializeParameters:-inherited}" />
    <logger name="slick.compiler.CodeGen"                   level="${log.qcomp.codeGen:-inherited}" />
    <logger name="slick.compiler.RemoveFieldNames"          level="${log.qcomp.removeFieldNames:-inherited}" />
    <logger name="slick.compiler.InsertCompiler"            level="${log.qcomp.insertCompiler:-inherited}" />
    <logger name="slick.compiler.VerifyTypes"               level="${log.qcomp.verifyTypes:-inherited}" />
    <logger name="slick.jdbc.DriverDataSource"              level="${log.jdbc.driver:-info}" />
    <logger name="slick.jdbc.JdbcBackend.statement"         level="${log.jdbc.statement:-info}" />
    <logger name="slick.jdbc.JdbcBackend.parameter"         level="${log.jdbc.parameter:-info}" />
    <logger name="slick.jdbc.JdbcBackend.benchmark"         level="${log.jdbc.bench:-info}" />
    <logger name="slick.jdbc.StatementInvoker.result"       level="${log.jdbc.result:-info}" />
    <logger name="slick.jdbc.JdbcModelBuilder"              level="${log.createModel:-info}" />
    <logger name="slick.memory.HeapBackend"                 level="${log.heap:-inherited}" />
    <logger name="slick.memory.QueryInterpreter"            level="${log.interpreter:-inherited}" />
    <logger name="slick.relational.ResultConverterCompiler" level="${log.resultConverter:-inherited}" />
    <logger name="slick.util.AsyncExecutor"                 level="${log.asyncExecutor:-inherited}" />
</configuration>
1

Have you tried turning off akka logging in application.conf?

akka {
  stdout-loglevel = "OFF"
  loglevel = "OFF"
}

See "Turning Off Logging" section in the documentation.

Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
1

The most common reason for the above steps mentioned not working is because your xx.xml logback file is not being read. Check if it is in the correct class path.

The only setting required in the xx.xml file to change level of slick logging is:

<logger name="slick"  level="INFO" />

In case of sbt, if the resources folder is not under src/main the path can be mentioned as follows:

resourceDirectory in Compile := baseDirectory.value / "conf"

When sbt assembly is done it will dump the logback configuration files into the fat jar

In case of running from jar

java -Dlogback.configurationFile=dev-logger.xml -Dfile.ending=UTF8  -cp $SCALA_HOME/lib/scala-library.jar  -jar myProject.jar -Dconfig.file=application.conf

In case from Intellij, ensure the folder containing the logback conf file like dev-logger.xml is marked as resources folder. If the configuration file is logback.xml it will take by default else you will need to mention it in the VM settings in run configuration

binshi
  • 1,248
  • 2
  • 17
  • 33