我是log4j的新手。我已經創建了一個實現log4j的示例java程序。日誌log4j中沒有生成文件
下面是Java程序:
package logging;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
public class Logging {
/**
* @param args the command line arguments
*/
private static Logger logger = Logger.getLogger(Logging.class);
public static void main(String[] args) {
BasicConfigurator.configure();
logger.trace("This is a Trace");
logger.debug("This is a Debug");
logger.info("This is an Info");
logger.warn("This is a Warn");
logger.error("This is an Error");
logger.fatal("This is a Fatal");
}
}
我收到的控制檯輸出screen.But的日誌文件不是如何產生。我也使用以下鏈接在Eclipse霓虹燈中配置了我的項目: Configuration
我已經做得很好。但日誌文件沒有generating.When我實現log4j的編程文件越來越以下generated.The是我屬性文件:
#root
log4j.logger.com.apress.logging.log4j=debug,dest
log4j.additivity.com.apress.logging.log4j=false
#define the appender
log4j.appender.dest = org.apache.log4j.DailyRollingFileAppender
#set the name of the file
log4j.appender.dest.File=${user.home}/log.out
#setting the immediate flush to true (default)
log4j.appender.dest.ImmediateFlush=true
#setting the threshold
log4j.appender.dest.Threshold=ERROR
#setting the append to false, overwrite
log4j.appender.dest.Append=true
#set the DatePattern
log4j.appender.dest.DatePattern='.' yyyy-MM-dd
什麼我需要做的有Log4J的寫日誌文件?
檢查該文件的appender配置:HTTPS://www.tutorialspoint。 COM/log4j的/ log4j_logging_files.htm – Maddy
嘗試使用 「-Dlog4j.configuration = your_configuration_file」 INS運行配置 –
的log4j:WARN沒有這樣的屬性[conversion'enter]在org.apache.log4j.PatternLayout ?? – lpgad