当我在本地机器(windows)中部署 wep 应用程序时,以下配置有效
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)
有什么建议吗?