Using Logback but Log4j started displaying WARN no Appenders

Chris Watts picture Chris Watts · Jan 14, 2013 · Viewed 17.1k times · Source

I am using logback for my logging and it has been working however; the other day I started getting a warning

log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle). log4j:WARN Please initialize the log4j system properly.

I am not using log4j nor have I ever with this project. I have a logback.xml in my resources folder.

Any ideas on why this warning started to show up?

Answer

theadam picture theadam · Jan 14, 2013

You must be using a library that does use log4j. Can you post anything more about your project?

You should probably just put log4j bridge on the classpath. Read more here: http://www.slf4j.org/legacy.html

The jar you want to look into is log4j-over-slf4j. It will bridge log4j API to actually make calls to your implementation of slf4j API (in your case - logback).

If you are using Maven to build your project then it might be as simple as putting

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>log4j-over-slf4j</artifactId>
    <version>1.7.7</version>
</dependency>

in dependencies.

Excluding a library (if needed) would be done in this fashion (this assumes we are talking about the transitive dependency from the jar you've mentioned):

    <dependency>
        <groupId>org.swift.common</groupId>
        <artifactId>jira-soap</artifactId>
        <version>4.4.0</version>
        <exclusions>
            <exclusion>
                <groupId>...</groupId>
                <artifactId>...</artifactId>
            </exclusion>
        </exclusions>
    </dependency>