0

I would like to reference external config file from logback. I have an external properties file that contains the datasource, some variables I use in controllers and log configurations. Is there a way to retrieve this variables from logback ?

grails.util.Holders.applicationContext.getBean('grailsApplication') does not work.

I know I'm using the externalconfig plugin, but if i want to reference a path set in applicaction.yaml is it possible ?

Dany Y
  • 6,833
  • 6
  • 46
  • 83

1 Answers1

0

I'm doubting that there is if Holders doesn't work, it probably hasn't been wired when the log file has been read. The one control you do have is you can set another logging file in your config like this: http://mrhaki.blogspot.com/2015/09/grails-goodness-use-different-logging.html

While you can simplify what you were using to Holders.config, in general Holders is a hack, and can be a pain when it comes to testing an app. Rather than use holders you should use injection in services, or wire up your class as a bean, using resources.groovy, or @Autowired (the file path has to be scanned for the annotation to work).

virtualdogbert
  • 462
  • 3
  • 12