我有以下build.sbt文件:
version := "0.1"
scalaVersion := "2.10.0-RC1"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
resolvers ++= Seq(
"sonatype releases" at "https://oss.sonatype.org/content/repositories/releases/",
"sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
"typesafe repo" at "http://repo.typesafe.com/typesafe/releases/",
"spray repo" at "http://repo.spray.io/"
)
libraryDependencies ++= Seq(
"io.spray" % "spray-can" % "1.1-M4.2"
,"io.spray" % "spray-routing" % "1.1-M4.2"
,"io.spray" % "spray-testkit" % "1.1-M4.2"
,"io.spray" %% "spray-json" % "1.2.2" cross CrossVersion.full
,"com.typesafe.akka" %% "akka-actor" % "2.1.0-RC1" cross CrossVersion.full
,"org.specs2" %% "specs2" % "1.12.2" % "test" cross CrossVersion.full
,"com.typesafe" % "slick_2.10.0-RC1" % "0.11.2"
,"com.h2database" % "h2" % "1.3.166"
,"org.xerial" % "sqlite-jdbc" % "3.6.20"
,"org.slf4j" % "slf4j-api" % "1.6.4"
,"ch.qos.logback" % "logback-classic" % "1.0.7"
,"org.specs2" % "specs2_2.10.0-RC1" % "1.12.2" % "test"
,"junit" % "junit" % "4.8.1" % "test"
)
如何为我自己的(当前)项目启用DEBUG级别报告,但为另一个项目禁用它。在这种情况下,我不希望看到Slick库的调试输出,但仍希望看到我自己项目的调试日志记录。
答案 0 :(得分:5)
在你的logback.xml中添加如下条目:
<logger name="com.typesafe.slick" level="INFO"/>
这意味着,当任何类型的命名空间com.typesafe.slick
获取记录器时,它将INFO
设置为日志级别。
编辑:这是指向documentation的链接。
答案 1 :(得分:0)
要查看您依赖的记录程序的名称,可以在logback.xml
中使用标准的记录附加程序。因此,如果您具有以下条件:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{1000} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
您将获得类似日志消息的信息:
12:53:09 [AmexReporting-akka.stream.default-blocking-io-dispatcher-6] 信息 net.schmizz.sshj .connection.channel.direct.SessionChannel- 将请求
sftp
子系统
然后,您可以在附加程序和根级别配置之间添加记录器:
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{1000} - %msg%n</pattern>
</encoder>
</appender>
<logger name="net.schmizz.sshj" level="OFF"/>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
记录器名称是您可以在日志输出中看到的部分或完整软件包名称,具体取决于您希望日志设置的粒度。