[quote=fabioebner]Pessoal estou precisando de ajuda, estou colocando o log4j no meu projeto… achei alguns exemplo bele.
fiz o seguinte log4j.properties
log4j.rootCategory = fileOut
log4j.appender.fileOut = org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileOut.DatePattern = '.'yyyy-MM-dd'.log'
log4j.appender.fileOut.Append = true
log4j.appender.fileOut.File = example.log
log4j.appender.fileOut.layout = org.apache.log4j.PatternLayout
log4j.appender.fileOut.layout.ConversionPattern = [%d] %t %c{1} %-5p: %m%n
log4j.appender.fileOut.Threshold = ERROR[/code]
no meu main eu fiz o seguinte:[code]
public class Main {
private static final Logger logger = Logger.getLogger(Main.class);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
BasicConfigurator.configure();
try {
// GerarCentraisNotas.gerarCentralCEP();
//GerarCentraisNotas.escrever("oi", "tudo", "Bom");
throw new Exception( "asss");
} catch (Exception e) {
e.printStackTrace();
}
}
nao teria ele q criar um exemplo.log ??? com esse erro q eu forcei???
ou eu etnho q toda fez q pode dar um erro… fazer alguma coisa
??
obrigado[/quote]
public class Main {
private static final Logger logger = Logger.getLogger(Main.class);
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
BasicConfigurator.configure();
try {
throw new Exception( "asss");
} catch (Exception e) {
e.printStackTrace();
logger.error("Salvar essa mensagem no arquivo de log.txt");
}
}
e no erro ologger.error("mensagem")
e pelo q eu estava vendo aqui essas opcoes
log4j.appender.fileOut = org.apache.log4j.DailyRollingFileAppender
log4j.appender.fileOut.DatePattern = '.'yyyy-MM-dd'.log'
nao tem q fazer ele gerar um arquivo de log com a data do dia???