以下配置工作時,我在本地機器上部署WEP的應用程序(窗口)Log4j配置在JSF的Web應用程序
public void contextInitialized(ServletContextEvent sce) {
Logger logger = null;
ServletContext servletContext = sce.getServletContext();
String prefix = servletContext.getRealPath("/");
String log4jFile = servletContext.getInitParameter("log4j");
if (log4jFile != null) {
DOMConfigurator.configure(prefix + log4jFile);
logger = LogManager.getLogger(StartupListener.class.getName());
logger.info("LOG4J loaded successfully: " + log4jFile);
}
}
<context-param>
<param-name>log4j</param-name>
<param-value>WEB-INF/classes/com/domain/resources/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>com.domain.util.StartupListener</listener-class>
</listener>
但在Linux中安裝Web應用程序時,我得到了以下錯誤信息:
log4j:ERROR Could not parse file [nullWEB-INF/classes/com/domain/resources/log4j.xml].
java.io.FileNotFoundException: /app/home/wdmt3/AdminServer/nullWEB-INF/classes/com/domain/resources/log4j.xml (No such file or directory)
有什麼建議嗎?
我不使用spring,基本上唯一有效的選擇是在weblogic中將服務器日誌記錄選項更改爲log4j – angus 2013-03-21 13:30:46
您是否嘗試過解決方案中的代碼?實際上你不需要使用彈簧。 – 2013-03-21 15:01:35
你是什麼意思「log4jFile以'/'開頭? – angus 2013-03-21 15:21:33