Skip to content

Instantly share code, notes, and snippets.

@jeffsheets
Created April 2, 2015 20:17
Show Gist options
  • Save jeffsheets/9bc4fe6b8fde2231f5da to your computer and use it in GitHub Desktop.
Save jeffsheets/9bc4fe6b8fde2231f5da to your computer and use it in GitHub Desktop.
Super Simple Spring Log4j Configuration using different files per environment
@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