【问题标题】:Maven filtering web.xml for Tomcat embedded in EclipseMaven 为 Eclipse 中嵌入的 Tomcat 过滤 web.xml
【发布时间】:2016-09-17 09:55:39
【问题描述】:
我目前有需要的情况
1) 有外部 log4j.properties
2)log4j.properties的位置在web.xml中配置为property占位符,property的值是从POM中读取的。
3) 占位符在构建时填充,即创建 .war 时
到目前为止,一切都很好 - 应用程序将 log4j 定位在 POM 中指定的位置并生成日志文件。但是,这仅在应用程序已作为 .war 部署到独立 Tomcat 实例时才有效。下一个要求是能够将其部署到嵌入在 Eclipse 中的 Tomcat,据我所知,这一步不涉及 Maven。部署到嵌入式 Tomcat 实例时,是否有任何方法强制 web.xml 填充其属性占位符?
提前致谢
安格斯
【问题讨论】:
标签:
eclipse
maven
tomcat
log4j
web.xml
【解决方案1】:
是的,我最后确实想出了一个解决方案。包括以下配置:
web.xml
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>${log4j.properties.location}</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
context.xml:
<Parameter name="log4j.properties.location" value="file:/usr/local/etc/xxxxxxxxx/xxxxxxxxxxxxx/log4j.properties"/>
你应该很高兴。