3,401 questions
1011
votes
40
answers
1.9m
views
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
My application is to be deployed on both tcServer and WebSphere 6.1. This application uses ehCache and so requires slf4j as a dependency.
As a result I've added the slf4j-api.jar (1.6) jar to my war ...
322
votes
3
answers
267k
views
How to log formatted message, object array, exception?
What is the correct approach to log both a populated message and a stack trace of the exception?
logger.error(
"\ncontext info one two three: {} {} {}\n",
new Object[] {"1",...
225
votes
5
answers
305k
views
How to configure slf4j-simple
api 1.7 and slf4j-simple as implementation. I just can't find how to configure the logging level with this combination.
Can anyone help out?
206
votes
7
answers
137k
views
How to use MDC with thread pools?
In our software we extensively use MDC to track things like session IDs and user names for web requests. This works fine while running in the original thread.
However, there's a lot of things that ...
197
votes
4
answers
130k
views
Is it worth to use slf4j with log4j2
I am not able to decide whether to use slf4j or not with log4j2. Based on online posts, does not look like it will have any performance hit but is it really required.
Also these points rule in favor ...
173
votes
13
answers
174k
views
How to intercept SLF4J (with logback) logging via a JUnit test?
Is it possible to somehow intercept the logging (SLF4J + logback) and get an InputStream (or something else that is readable) via a JUnit test case...?
163
votes
1
answer
112k
views
What are markers in Java Logging frameworks and what is a reason to use them?
The first time I heard about markers was while reading:
http://slf4j.org/faq.html
I checked available methods for the Logger object:
http://www.slf4j.org/api/org/slf4j/Logger.html
http://logging....
145
votes
5
answers
97k
views
What is the difference between Log4j, SLF4J and Logback?
I am little bit confused by these three logger libraries. It seems like that they can do the similar thing in Java logging...
125
votes
11
answers
71k
views
How do you configure logging in Hibernate 4 to use SLF4J
Hibernate 3.x used slf4j for logging. Hibernate 4.x uses jboss-logging. I am writing a standalone application which uses Hibernate 4, and SLF4J for logging.
How can i configure Hibernate to log to ...
121
votes
2
answers
86k
views
How to log exception and message with placeholders with SLF4J
What's the correct approach to log both an error message and an exception using SLF4J?
I've tried doing this but the exception stack trace is never printed:
logger.error("Unable to parse data {}", ...
110
votes
3
answers
111k
views
Logging framework incompatibility
I'm building a small Java app and hoping to use logback for logging.
My app has a dependency on an older project that does its logging via
org.apache.commons | com.springsource.org.apache.commons....
92
votes
19
answers
117k
views
What is the best way to unit-test SLF4J log messages?
I'm using slf4j and I want to unit test my code to make sure that warn/error log messages are generated under certain conditions. I'd rather these be strict unit tests, so I'd prefer not to have to ...
81
votes
26
answers
143k
views
Spring Boot - no log file written (logging.file is not respected)
I use Spring Boot and want it to write log output to a file.
According to the docs, this is simply done by setting
logging.file=filename.log
While the console output works fine, filename.log is not ...
80
votes
5
answers
189k
views
Where does the slf4j log file get saved?
I have the followed imports:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
and the following instantiation:
private static Logger logger = LoggerFactory.getLogger(Test.class);
and the ...
74
votes
10
answers
155k
views
How to enable debug in slf4j Logger?
How to globally enable debug for all the slf4j.Logger objects?
66
votes
3
answers
53k
views
Is there a correct way to pass arguments in slf4j?
Im using slf4j for tracing the information. My code is
private static final Logger log = LoggerFactory.getLogger(ObjectTest.class);
log.trace("Time taken to store " + count
+ " objects ...
60
votes
5
answers
70k
views
Spring cache logging on @Cacheable hit
Currently I am working with a Spring Cache and the @Cacheable/@CacheEvict annotations.
I would like to get some sort of a console log statement like "INFO: i got those values from the cache, NOT from ...
60
votes
5
answers
13k
views
How to find which library slf4j has bound itself to?
I am using slf4j for logging in my application.
I get the purpose of slf4j. I would like to know how to find out which logging-library slf4j is currently binding to. I have log4j in my referenced ...
59
votes
10
answers
212k
views
ClassNotFoundException: org.slf4j.LoggerFactory
I am trying to run GWT RequestFactory and facing this error:
ClassNotFoundException: org.slf4j.LoggerFactory
I have tried to download slf4j-api-1.3.1.jar but it didnt resolve the issue
Any idea ...
58
votes
3
answers
39k
views
Which Android logging framework to use? [closed]
My question seems to be easily answerable, but there are several good solutions.
I like to choose the 'best' one.
Available frameworks (feel free to suggest more):
Androlog
SLF4J Android
Log4J - ...
56
votes
2
answers
40k
views
How to create 2 different ROOT loggers with logback?
I'm happily using SLF4J with Logback and use 2 appenders for the ROOT logger as follows:
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref=...
54
votes
6
answers
205k
views
NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
I'm trying to run the sample tiles example given here.
Below is my POM.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<...
52
votes
4
answers
49k
views
How to exclude commons-logging from a scala/sbt/slf4j project?
My scala/sbt project uses grizzled-slf4j and logback. A third-party dependency uses Apache Commons Logging.
With Java/Maven, I would use jcl-over-slf4j and logback-classic so that I can use logback ...
49
votes
6
answers
21k
views
Is Log4j being abandoned in favor of Slf4j? [closed]
It seems that log4j has some class loading issues (among others) and it seems to me the trend is to move out of log4j toward slf4j. (Hibernate stopped using the first in favor of the latter)
Is it ...
48
votes
11
answers
87k
views
Why calling LoggerFactory.getLogger(...) every time is not recommended?
I've read tons of posts and documents (on this site and elsewhere) pointing that the recommended pattern for SFL4J logging is:
public class MyClass {
final static Logger logger = LoggerFactory....