-1
我打算在應用程序中使用兩個不同的日誌文件。 Log4j的配置文件是這樣的:Log4j沒有找到記錄器的appender
log4j.rootLogger= false
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File= D\:\\default.log
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.instLog = org.apache.log4j.FileAppender
log4j.appender.instLog.File= D\:\\install.log
log4j.appender.instLog.DatePattern='.'yyyy-MM-dd
log4j.appender.instLog.Append=true
log4j.appender.instLog.layout=org.apache.log4j.PatternLayout
log4j.appender.instLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.appender.updateLog = org.apache.log4j.FileAppender
log4j.appender.updateLog.File= D\:\\update.log
log4j.appender.updateLog.DatePattern='.'yyyy-MM-dd
log4j.appender.updateLog.Append=true
log4j.appender.updateLog.layout=org.apache.log4j.PatternLayout
log4j.appender.updateLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
和Java代碼是這樣的:
public class AppTest {
private static Logger update = Logger.getLogger("update.log");
private static Logger install = Logger.getLogger("install.log");
public static void main(String[] args) {
update.info("Update");
install.info("Install");
}
}
,但在運行時我得到這個:
log4j:WARN No appenders could be found for logger (update.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
哪裏錯了?
粘貼你的整個的log4j .xml文件。 – SMA
@almasshaikh我只是把所有內容的log4j.properteise –