8

我有以下 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"
)

如何为我自己的(当前)项目启用调试级别报告,但为另一个项目禁用它。在这种情况下,我不想看到 Slick 库的调试输出,但仍想查看我自己项目的调试日志。

4

2 回答 2

5

在您的 logback.xml 中添加如下条目:

<logger name="com.typesafe.slick" level="INFO"/>

这意味着,当命名空间的任何类获取记录器时,com.typesafe.slick它将INFO设置为日志级别。

编辑:这是文档的链接。

于 2012-11-08T10:45:54.003 回答
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] INFO net.schmizz.sshj .connection.channel.direct.SessionChannel - 将请求sftp子系统

然后您可以在 appender 和根级别配置之间添加一个记录器:

<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>

记录器名称是您可以在日志输出中看到的一部分或完整包名称,具体取决于您希望日志设置的粒度。

于 2018-11-22T11:58:08.950 回答