log4j warning issue - apache commons

14,391

Solution 1

Log4J outputs this error when a logger is created, but no appender(s) is(are) defined. In practice this error occurs when a logger is created before log4j is initialized.

You say you haven't called any log4j object. But in the error message you see that org.apache.commons.configuration.ConfigurationUtils creates a logger object (see line 66).

You could turn it off before initialization, see How to turn off log4j warnings?

Logger.getRootLogger().setLevel(Level.OFF);

There should be no need to turn it on again since the initialization sets normally the log level of the root logger.

Solution 2

Check if the log4j.properties file is in the classpath

This link might be useful: http://www.coderanch.com/t/63230/open-source/log-log-WARN-No-appenders

Share:
14,391
Matteo Codogno
Author by

Matteo Codogno

I'm Technical Leader at WellD, a software house delivering innovative solutions in the domains of Energy, Industry automation and Health. I love to experiment with new technologies, open source projects and design Software architectures (I am a kid in a candy store!).

Updated on June 04, 2022

Comments

  • Matteo Codogno
    Matteo Codogno almost 2 years

    I'm using apache commons library and log4j. I have an xml configuration file and a log4j.properties files. I want to specify my log4j properties path inside my xml configuration file. To load my settings i do:

    //Loading my xml file
    this.config = new XMLConfiguration(this.xmlFileName);  
    

    At this moment the following warnings are raised:

    log4j:WARN No appenders could be found for logger (org.apache.commons.configuration.ConfigurationUtils).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
    

    However i haven't yet called any log4j object. Once i have read the xml file i can successfully work with my log4j instance. Is there any way to remove those warnings?

  • Matteo Codogno
    Matteo Codogno about 12 years
    I don't want insert my log4j.properties in the classpath, because it is placed external to the jar and in another directory. I want load it at run-time, using the path specified in my application configuration file.
  • Matteo Codogno
    Matteo Codogno about 12 years
    Ok, are there any way to disable LOG inside the 'org.apache.commons.configuration.ConfigurationUtils' or configure my log4j properties insied my xml configuration?
  • ChrLipp
    ChrLipp almost 12 years
    Isn't this the solution I suggested in my comment under my post?