I am loading log4j.xml using the traditional way
log4jConfigLocation
classp
It's too late to help adeelmahmood, but hope others will benefit from my answer. The thing is adeelmahmood was right, this configuration:
log4jConfigLocation
classpath:conf/log4j-${ENV-NAME}.xml
org.springframework.web.util.Log4jConfigListener
is working, but:
Then, if ENV-NAME environment variable is set, it works as expected.
By the way, ${ENV-NAME} can be used in spring config files as well! That's not everything... You can also use our env.property to set spring profile:
spring.profiles.active
${ENV-NAME}
This way you can set log4jConfigLocation and spring profile, both with one and the same env. variable.
BTW and just in case: using Maven profiles to have separate builds for dev, test and production isn't good practice. Read eg. http://java.dzone.com/articles/maven-profile-best-practices and remember: "Use profiles to manage build-time variables, not run-time variables and not (with RARE exceptions) alternative versions of your artifact".