Init log4j2 via Spring Log4jConfigurer

Half of the Spring provided Log4j 1.2 support is done, but unfortunately not the bit you're after (for which you'd need to dive into the Log4j2 Configurator class).

For web applications, reading the docs (and code where docs were not enough) at http://logging.apache.org/log4j/2.x/log4j-web/index.html, it seems you can use Log4J2's own configurer which does parameter substitution, and will load from the classpath.

Add the following to your pom.xml:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-web</artifactId>
    <version>2.0-beta6</version>
</dependency>

And in your web.xml, use the following:

<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>classloader:/config/env/log4j-${sys:env.variable}.xml</param-value>
</context-param>
<listener>
    <listener-class>org.apache.logging.log4j.core.web.Log4jContextListener</listener-class>
</listener>

Note the / after classloader: and that Log4j2 requires a sys: prefix before the env variable

*However, so far, I've not been able to get this to work on a straight migration from the Spring Log4jContextListener. It seems that Log4j2 has promise, but for now it looks like adoption will remain on a branch until it doesn't have so many gotchas, and has better documentation *