Questions tagged [slf4j]

Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction layer for various logging frameworks. Please also include a tag for the actual logging framework you're using if you are attempting to configure logging for your application.

The Simple Logging Facade for Java (commonly known as "SLF4J") serves as a simple facade or abstraction layer for various logging frameworks, e.g. java.util.logging, log4j and logback.

One can unify all logging across an application and the libraries it uses via this abstraction layer. Code familiar with SLF4J uses the SLF4J API directly for logging. Any existing code or libraries that use some other logging framework can be bridged to get their logging redirected to SLF4J instead. The end application at deployment time includes a binding to the actual logging framework that they are using, and can configure that logging framework as desired for all logging throughout the application.

References:

3285 questions
26
votes
7 answers

Multiple SLF4J bindings cause error?

I have a problem with my dependency tree and multiple SLF4J binding. What I found out so far is that usually this only causes a warning but in my case it seems to prevent my program from running: These are the exceptions I get: SLF4J: Class path…
Biffy
  • 871
  • 2
  • 10
  • 21
26
votes
4 answers

NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()

The issue was caused by one of the dependencies in my pom.xml [cxf-bundle-jaxrs] which internally uses lower version of slf4j. I managed to resolve this issue by upgrading this dependency to the latest release. Thanks everyone. I'm trying to add…
enfany
  • 875
  • 2
  • 15
  • 33
25
votes
2 answers

Maven + SLF4J: Version conflict when using two different dependencies that require two different SLF4J versions

I have a project that use both dependencies independently: BoneCP and Hibernate. But thanks to SLF4J and its version conflicts it does not work because BoneCP requires SLF4J 1.5 and Hibernate requires SLF4j 1.6. As you know it is not possible to…
chrisapotek
  • 6,007
  • 14
  • 51
  • 85
25
votes
2 answers

I'm getting "NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil"

I have the following dependencies in my build.gradle file. compile 'org.slf4j:slf4j-api:1.7.25' compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1' compile group: 'org.apache.logging.log4j', name: 'log4j-api', version:…
hisdudeness
  • 438
  • 1
  • 5
  • 15
25
votes
3 answers

error: package org.slf4j does not exist

I am attempting to create a program in Java using Netbeans. I am attempting to use org.slf4j. I think I have placed the sufficient amount of slf4j jar files in my CLASS PATH. I have placed slf4j-api, slf4j-jcl, slf4j-jdk14, slf4j-nop and…
Vutana
  • 267
  • 1
  • 3
  • 6
25
votes
3 answers

How to disable Spring logging DEBUG messages?

I'm working on a simple desktop app (not webapp). Here is my log4j.properties: log4j.rootCategory=INFO,…
rapt
  • 11,810
  • 35
  • 103
  • 145
25
votes
1 answer

How can I change log level of single logger in runtime?

I wanna read spring property and based on this property change log level for some packages (not for root logger). How can I implement it using logback?
fedor.belov
  • 22,343
  • 26
  • 89
  • 134
24
votes
4 answers

Any reason to use private instead of private final static on the LogBack Logger?

When instantiating Logger in a Spring Controller, is there any reason to declare it as a static final? The Logger is not used outside MyController.class. I've seen both examples in use, but can't see why I should use one or the other. private…
Tommy
  • 4,011
  • 9
  • 37
  • 59
24
votes
7 answers

Is there a Java 1.5 varargs API for slf4j yet?

I want to get rid of this lot... public void info(String msg); public void info(String format, Object arg); public void info(String format, Object arg1, Object arg2); public void info(String format, Object[] argArray); ...and replace it with this…
Josh
  • 4,894
  • 6
  • 34
  • 42
24
votes
3 answers

java.lang.ClassNotFoundException: org.apache.log4j.Level

I'm trying to use hibernate 3.5.1 final in a swing application and here are the jars I'm…
Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498
23
votes
6 answers

Is it worth wrapping a logging framework in an additional layer?

I'm currently looking at upgrading the logging mechanism in a medium-to-large-sized Java codebase. Messages are currently logged using static methods on a Debug class, and I have recommended switching from this to something like SLF4J or…
harto
  • 89,823
  • 9
  • 47
  • 61
23
votes
3 answers

How does simply adding slf4j to the pom.xml wrap log4j?

From what I have seen in example spring pom.xml files is that they add a few entries for slf4j and log4j and somehow when you use log4j in your spring application it will be wrapped by slf4j library. Can someone explain to me how this magically…
codecompleting
  • 9,251
  • 13
  • 61
  • 102
23
votes
4 answers

How to get logging working in scala unit tests with testng, slf4s, and logback

I'm new to Scala, and not that familiar with recent developments in Java, so I am having what I assume is a basic problem. I'm writing some Scala code, and testing it with test fixtures using ScalaTest and TestNG. The code under test uses slf4s to…
anelson
  • 2,569
  • 1
  • 19
  • 30
23
votes
6 answers

Hibernate 3.4 with slf4j and log4j

I'm attempting to upgrade from Hibernate 3.2 to 3.4, which apparently uses slf4j. Our project currently uses log4j. So my assumption is that I should be using the slf4j-log4j12 wrapped implementation. The Maven slf4j dependency is:
Steve Kuo
  • 61,876
  • 75
  • 195
  • 257
23
votes
2 answers

Logging using SL4J, Jakarta Commons logging, log4j for third party libraries and my own code

I have some questions about logging, more specifically about setting it up and making sure it works. The project I'm doing will use Wicket, Spring and Hibernate. I know that Wicket and Hibernate uses Simple Logging Facade for Java (SL4J) and that…
user14070