Created
April 2, 2015 20:17
-
-
Save jeffsheets/9bc4fe6b8fde2231f5da to your computer and use it in GitHub Desktop.
Super Simple Spring Log4j Configuration using different files per environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class SpringLog4jConfig { | |
/** | |
* Just a property from the normal Spring property sources, like: | |
* log4j.properties.location=log4j-dev.properties | |
*/ | |
@Value("${log4j.properties.location}") | |
String log4jLocation; | |
/** | |
* Make sure the file specified by the log4j.properties.location value is on the classpath | |
*/ | |
@PostConstruct | |
void initializeLog4j() throws FileNotFoundException { | |
Log4jConfigurer.initLogging("classpath:" + log4jLocation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment