scala - How to find out, which backend is used for slf4j logging, in third-party library? -


I am using Scala library to create HTTP requests called B-Client. Bee-client prints lots of debugging information from the console for each task, it is using the slf4j framework to do this.

My problem is to disable logging and redirect it to the file.

I have tried different ways to disable java.util.logging, but they do not matter at all. Finally I realized that slf4j can use other backends, but I do not know how it is recognized.

So I can use both logs and source code of B-client. To understand which logging is using the backend?

Given the momentary dependence of the dependency of interest, you can find out what kind of The logging framework uses it In many cases it will use some kind of Java logging API and will provide you the implementation of the lagoon which you like. For example, see this Maven Build file for your project.

How to set up B-Client in your project In fact, what can we learn from SBT dependencies:

  libraryDependencies ++ = Seq ("uk.co. Bigbeeconsultants "%%" bee "%" 0.21. "", "Org. Slf4j"% "slf4j-api"% "1.7.", "Ch.qos.logback"% "lockback-core"% "1.0." , "Ch.qos.logback"% "logback-classic"% "1.0. +") + Revolver + = "Big Bee Consultants" on "http://repo.bigbeeconsultants.co.uk/repo"  < / Pre> 

This uses the slf4j API and logback logging for the implementation log-in configuration set There are a number of dependencies listed above in your project. For example, create a config file anywhere on the classpath (possibly here: src / main / resources / logback XML). Add this content to it And you are all set:

  & lt; configuration & gt; & lt; appender name = "FILE" class = "ch.qos.logback.core.FileAppender"> & lt ; File & gt; myApp.log & lt; / file & gt; & lt; encoder & gt; & Lt; Pattern & gt;% date% level [% thread]% logger {10} [% file:% line]% msg% n & lt; / Pattern & gt; & Lt; / Encoder & gt; & Lt; / Appender & gt; & Lt; Appender name = "STDOUT" class = "ch.qos.logback.core.ConsoleAppender" & gt; & Lt; Encoder & gt; & Lt; Pattern & gt;% msg% n & lt; / Pattern & gt; & Lt; / Encoder & gt; & Lt; / Appender & gt; & Lt; Root level = "debug" & gt; & Lt; Epander-Reef Ref = "FILE" /> & Lt; Appender-Riffe = "STDOUT" /> & Lt; / Root & gt; & Lt; / Configuration & gt;  

See more details about how to configure logback.


Comments