How do I disable logging for a specific dependency in SBT?

*爱你&永不变心* 提交于 2019-12-05 04:08:46

In your logback.xml add an entry like this:

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

This means, that when a logger is obtained by any class of the namespace com.typesafe.slick it will have INFO set as log level.

edit: Here's the link to the documentation.

To see what name the logger of you dependency have you can use the standard logging appender in your logback.xml. So if you have the following:

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

You will get something like as a log message:

12:53:09 [AmexReporting-akka.stream.default-blocking-io-dispatcher-6] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Will request sftp subsystem

Then you can add a logger between the appender and root level configuration:

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

Where the logger name is a part or the full package name that you can see in the log output, depending on how granular you want your log settings to be.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!