• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

org.slf4j.LoggerFactory-logs to SystemOut even if configured to log to a specific file:jar conflict?

 
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm experiencing some issue with the logger slf4j which is being used into sever classes into my project.
Even if I configured the logger in order to write into a specific file, it prints into SystemOut.log.

I am pretty sure it could be a jar conflict, but I cannot figure out what jar can be removed and what jar has to stay there.

Here's the list of the (logging) jars I am using in the project:
slf4j-api-1.6.4.jar
log4j-1.2.15.jar
commons-logging-1.2.jar
logback-classic-1.0.0.jar


Even if I change the appender-ref, only to go to a specific appender (RollingFileAppender - to another file), it doesn't work.

Can somebody help me to debug such a mess please?
 
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're missing the bridge between SLF4J and Log4J (slf4j-log4j12-1.6.4.jar).

Just a hint by the way: upgrade to at least version 1.7. That added varargs so you don't have to manually create arrays if you want to have more than 2 arguments to your logging methods.
 
Francesco Bellini
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Rob,

I've added slf4j-log4j12-1.7.12 as dependency, and upgraded slf4j-api to 1.7.12 as well.
Nothing has changed yet, but this is what I can see in the Console when the webapp starts:


SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/apache-tomcat-7.0.34/wtpwebapps/webapp-test/WEB-INF/lib/logback-classic-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file://apache-tomcat-7.0.34/wtpwebapps/webapp-test/WEB-INF/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

Of course, I've already performed a search on google about it, but after many attempts, I wasn't able to solve.
Removing logback-classic from my pom.xml causes no logging at all both in systemout and the log file configured.
 
Rob Spoor
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have Log4J configured to do any logging?
 
Francesco Bellini
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, of course:

here's the log file:


EDIT: this is what I see after removing logback-classic from the pom.xml file.
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.

This is a spring-mvc web application by the way.
 
Francesco Bellini
Ranch Hand
Posts: 42
Oracle Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After playing a little bit within the web.xml configuration and removing logback-classic, I figured out how to get the logger working:

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic