Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn Slick logging off

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:
like image 498
Arthur C Avatar asked Apr 15 '14 15:04

Arthur C


4 Answers

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.

like image 177
Arthur C Avatar answered Oct 08 '22 21:10

Arthur C


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>
like image 40
Janaka Priyadarshana Avatar answered Oct 08 '22 20:10

Janaka Priyadarshana


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

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

See "Turning Off Logging" section in the documentation.

like image 21
Andriy Drozdyuk Avatar answered Oct 08 '22 21:10

Andriy Drozdyuk


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

like image 32
binshi Avatar answered Oct 08 '22 22:10

binshi