Slick用大量的日志消息填满了控制台。我希望像文档建议一样使用slf4j-nop
,因此关闭日志记录,但Akka需要自己的slf4j库。
所以我离开了Slick也使用的akka-slf4j_2.10
。我尝试了很多东西。我的application.conf
中包含此内容(尝试使用和不使用"):
logger="OFF"
logger.scala.slick="OFF"
logger.scala.slick.session="OFF"
logger.scala.slick.jdbc.JdbcBackend.statement="OFF"
logger.scala.slick.jdbc="OFF"
它没有效果。 有人可以帮我关掉这个日志,这样我就可以再次喜欢Slick吗?
我得到的一些日志消息:
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:
答案 0 :(得分:28)
我通过向logback.xml
添加src/main/resources
来修复它:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="scala.slick" level="INFO" />
</configuration>
答案 1 :(得分:1)
您是否尝试在application.conf
中关闭akka日志记录?
akka {
stdout-loglevel = "OFF"
loglevel = "OFF"
}
参见&#34;关闭记录&#34; documentation中的部分。
答案 2 :(得分:1)
给定here的logback.xml文件解决了我的问题。
<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>
答案 3 :(得分:1)
上述步骤不起作用的最常见原因是因为未读取xx.xml logback文件。检查它是否在正确的类路径中。
xx.xml文件中唯一需要更改光滑日志记录级别的设置是:
<logger name="slick" level="INFO" />
如果是sbt ,如果资源文件夹不在src / main下,则可以按如下方式提及路径:
resourceDirectory in Compile := baseDirectory.value / "conf"
当sbt程序集完成时,它会将logback配置文件转储到fat jar
如果从jar
运行java -Dlogback.configurationFile=dev-logger.xml -Dfile.ending=UTF8 -cp $SCALA_HOME/lib/scala-library.jar -jar myProject.jar -Dconfig.file=application.conf
如果来自Intellij,请确保将包含dev-logger.xml等logback conf文件的文件夹标记为resources文件夹。如果配置文件是logback.xml,则默认情况下需要在运行配置中的VM设置中提及它