Log4J输出至当前web路径
通过Spring提供的一个类,可以辅助log4j配置文件将日志文件输出至应用程序的相对路径 这个类是 org.springframework.web.util.Log4jConfigListener 这个类通过监听器将应用程序的路径设到System的property里,从而可以将代表应用程序路径的property作为log4j的输出路径 log4j.appender.R.File=${ webapp.root }/log/log.log source code : public static final String WEB_APP_ROOT_KEY_PARAM = "webAppRootKey";//web.xml的context-param public static final String DEFAULT_WEB_APP_ROOT_KEY = "webapp.root";//web.xml默认的context-key String root = servletContext.getRealPath("/");//获取应用程序路径 ...... String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);//根据context-param获取context-key String key =