任何人都可以帮助我解决这个问题我收到此警告消息
log4j:WARN No appenders could be found for logger (com.akak.book.shop.listener.LogContextListener).
log4j:WARN Please initialize the log4j system properly.
班上:
public class LogContextListener implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent ctxEvent) {
}
@Override
public void contextInitialized(ServletContextEvent ctxEvent) {
ServletContext ctx = ctxEvent.getServletContext();
String path = ctx.getRealPath("/") + "logs\\";
System.setProperty("jlcindia.root.path", path);
String str = ctx.getRealPath("/WEB-INF/classes/com/jlc/jlc-log4j.properties");
PropertyConfigurator.configure(str);
Logger log = Logger.getLogger(this.getClass());
log.info("Properties file:"+ str);
}
}
jlc-log4j.properties 文件:我这样指定
log4j.rootLogger = ERROR.jlc
log4j.appender.jlc = org.apache.log4j.FileAppender
log4j.appender.jlc.file = ${jlcindia.root.path}/jlcindia.log
log4j.appender.jlc.layout = org.apache.log4j.PatterLayout
log4j.appender.jlc.layout.ConversionPattern = %p %l %m %n