23

It's a third party application generating huge amounts of log entries on our app server. Like this:

[03.03.10 15:21:57:250 CET] 00000180 FtpProtocolHa I org.slf4j.impl.JCLLoggerAdapter info Close connection : 10.227.10.10 - admin
[03.03.10 15:27:35:209 CET] 00000181 MinaFtpProtoc I org.slf4j.impl.JCLLoggerAdapter info [/10.227.10.10] CLOSED
++++

How do I turn this output from SLF4J off? I've looked in the .war file to find some configuration for SLF4J but nothing. Their website didn't help either.

Mahozad
  • 18,032
  • 13
  • 118
  • 133
Tommy
  • 4,011
  • 9
  • 37
  • 59

6 Answers6

17

slf4j is just a funnel to the actual log backend (here overriding jakarta commons logging), which is the one you must configure to get rid of a certain kind of messages. For logback this is the appropriate configuration snippet which goes in your logback.xml configuration file:

    <!--  No Tomcat debug logs -->
    <configuration>
    ...
        <logger name="org.apache.catalina.core" level="OFF" />
    ...
    </configuration>

For log4j it is very similar.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
15

Alternatively, download http://www.slf4j.org/dist/slf4j-1.6.4.tar.gz, look in there for slf4j-nop-1.6.4.jar (this is the no-operation logger) and include this in your classpath. When the SLF4J classloader sees this (it looks to see what loggers are in the classpath that it can use), it should stop logging (once you've restarted the app).

At least this way you don't need to mess with the log configuration files...

sparkyspider
  • 13,195
  • 10
  • 89
  • 133
  • On my system I had to also remove slf4j-log4j*.jar from my classpath. – philwalk Jun 05 '18 at 19:23
  • 1
    slf4j will dislike intensely if you have more than one slf4j backend in the classpath. – Thorbjørn Ravn Andersen Feb 06 '19 at 14:47
  • I am using maven, I added the dependency that Mr Zorn suggested, I changed other slf4j dependencies to all have the same version, as Thorbjørn Ravn Andersen suggested, but I am still seeing the logs from the external library. – vefthym Nov 05 '19 at 19:03
4

As stated by @sparkyspider answer, you can simply add the slf4j-nop library to your application.

If using Maven, add this to your pom.xml file:

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-nop</artifactId>
        <version>1.7.36</version>
    </dependency> 
</dependencies>

If using Gradle, add this to your build.gradle[.kts] file:

dependencies {
    implementation("org.slf4j:slf4j-nop:1.7.36")
}
Mahozad
  • 18,032
  • 13
  • 118
  • 133
3

slf4j is a logging facade for various logging frameworks. That output comes from the Apache Commons Loggin framework adapter, that turns to be another facade. Commons Logging Configuration.

rodrigoap
  • 7,405
  • 35
  • 46
3

Which logging back-end, e.g. logback, log4j, j.u.l., are you using? You need to configure the backend to filter those messages.

Moreover, the fact that the log messages point to "org.slf4j.impl.JCLLoggerAdapter" indicates that caller location inference is not working correctly. (It should mention the actual caller not JCLLoggerAdapter). This can happen if:

  1. you are using an older version of SLF4J

or

  1. the caller is using a slf4j-like wrapper or has its own homegrown logging API which does not infer caller location properly. See also a relevant SLF4J FAQ entry.
shA.t
  • 16,580
  • 5
  • 54
  • 111
Ceki
  • 26,753
  • 7
  • 62
  • 71
  • This is a third party application. I don't have access to any code (other than decompiling) There are no log4j.properties files or any other files that look like they containt any log-properties – Tommy Mar 05 '10 at 12:58
1

Search for the following string: level="DEBUG" using your IDE. You will find that text in a .xml file.

Go there and use level="INFO" instead of level="DEBUG".

The key value is not case-sensitive.

There can be something like:

<root level="info">
    ...
</root>
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199