0
我有以下log4.properties:log4j的警告:沒有追加程序發現
log4j.rootLogger=WARN,console
log4j.rootCategory=debug,A1,D
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%p %d{MM/dd/yyyy HH:mm:ss} %x %c - %m%n
log4j.appender=org.apache.log4j.RollingFileAppender
log4j.appender.D.File=c:/opt/logs/MyLogs.log
log4j.appender.D.layout=org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern=%p %d{MM/dd/yyyy HH:mm:ss} %x %c - %m%n
我將它鏈接到我的項目中使用Java選項「-Dlog4j.configuration = C:\選擇\設置\ log4j.properties 「
在我的Java代碼中,我導入log4j.Logger然後實例吧:
public static final Logger logger = Logger.getLogger("testServlet.class");
但是我仍然得到log4j的警告並沒有得到生成的日誌文件:
log4j:WARN No appenders could be found for logger (testServlet.class).
log4j:WARN Please initialize the log4j system properly.
我在做什麼錯?