Olá Pessoal,
Estou tentando gerar um arquivo de log e está aparecendo esse erro:
log4j:WARN No appenders could be found for logger (br.com.util.LoggingTest).
log4j:WARN Please initialize the log4j system properly.
Classe de teste:
public class LoggingTest {
static Logger logger = Logger.getLogger(LoggingTest.class.getName());
public static void main(String[] args) {
logger.setLevel(Level.INFO);
logger.debug("Isso nao vai aparecer...");
logger.info("Inicilizando...");
try {
throw new Exception("Loga esse, Log4J!");
} catch (Exception e) {
logger.error("erro: " + e.getMessage());
}
logger.info("Finalizando...");
}
}
Properties
Use two appenders, one to log to console, another to log to a file
log4j.rootCategory=info, ind
First appender writes to console
log4j.appender.ind=org.apache.log4j.ConsoleAppender
log4j.appender.ind.layout=org.apache.log4j.PatternLayout
Pattern to output the caller’s file name and line number.
log4j.appender.ind.layout.ConversionPattern=%5p [%t] (%F%L) - %m%n
Second appender writes to a file
log4j.appender.ind=org.apache.log4j.RollingFileAppender
log4j.appender.ind.File=C:\temp2\import.log
Control the maximum log file size
log4j.appender.ind.MaxFileSize=10000KB
Archive log files (one backup file here)
log4j.appender.ind.MaxBackupIndex=10
log4j.appender.ind.layout=org.apache.log4j.PatternLayout
log4j.appender.ind.layout.ConversionPattern=%p %t %c - %m%n
Coloquei meu arquivos properties em várias pastas do projeto , porém apresenta o mesmo erro
log4j:WARN No appenders could be found for logger (br.com.util.LoggingTest).
log4j:WARN Please initialize the log4j system properly.
Vlw pela ajuda