Log4j2 与Spring 使用webAppRootKey

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>webApp.root</param-value>
    </context-param>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>WEB-INF/classes/log4j2.xml</param-value>
    </context-param>

    <context-param>
        <param-name>log4jRefreshInterval</param-name>
        <param-value>3000</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

以上是web.xml 文件需要的配置

在log4j2 的xml文件中,使用“${sys:webApp.root}”,因为webApp.root是system properties,所以必须使用sys前缀。

你可能感兴趣的:(spring,log4j2,webAppRootKey,webapp.root)