How to resolve the "No appenders could be found for logger" warning?

4

I'm trying to set up Log4j in my project with JSF. I followed all the steps in a tutorial I found on Youtube . However, the following message is being posted:

log4j:WARN No appenders could be found for logger (br.com.hidros.control.beans.ControleBean).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

I'm using log4j-1.2.17.jar .

My file log4j.properties is already in the console of the WEB-INF folder and in my class I did this:

public class ControleBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final Logger log = Logger.getLogger(ControleBean.class);

And catchs :

catch (ConnectException ex) {
    contarTentativas();
    System.out.println("ConnectException de ControleBean.verificarReles(Placa placa) (PLACA ="+placa.getIpPlaca()+")");
    log.info("ConnectException de ControleBean.verificarReles(Placa placa)");
    log.debug(ex, ex);          
}

My file log4j.properties looks like this:

log4j.rootCategory=DEBUG, R, O

log4j.appender.O=org.apache.log4j.ConsoleAppender

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=log4j.log

log4j.appender.R.MaxFileSize=100KB

log4j.appender.R.MaxBackupIndex=10

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.O.layout=org.apache.log4j.PatternLayout

log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
log4j.appender.O.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
    
asked by anonymous 11.11.2015 / 18:00

1 answer

3

The log4j.properties file should be placed in the WEB-INF/classes folder of your application. If it is only in WEB-INF or in another directory it will not work.

This is documented in the Log4j manual .

    
12.11.2015 / 06:34