I'm trying to configure Grails so as to use external Log4j2 configuration files separating production and development mode. It should listen for configuration changes and refresh it after some period of time.
For Grails 2.x, it can be done by registering Log4jConfigurer beans like this:
switch (Environment.current) {
case Environment.PRODUCTION:
log4jConfigurer(MethodInvokingFactoryBean) {
targetClass = "org.springframework.util.Log4jConfigurer"
targetMethod = "initLogging"
arguments = ["classpath:ogc-log4j.xml", 30000]
}
case Environment.DEVELOPMENT:
log4jConfigurer(MethodInvokingFactoryBean) {
targetClass = "org.springframework.util.Log4jConfigurer"
targetMethod = "initLogging"
arguments = ["classpath:log4j-dev.xml", 30000]
}
}
For some reasons, this approach doesn't work in Grails 3.x. How can I do this in Grails 3.3.3 or in Spring Boot (I guess it should work because Grails 3.x is based on Spring Boot)?