I have variables with defaults in my logback.xml
configuration file, and I would like to be able to optionally set these variables from my typesafe config app
I chose to programmatically configure logback having typesafe config. It turned out to be easy.
def enableRemoteLogging(config: Config) = {
val ctx = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext]
val gelf = new GelfAppender
gelf.setGraylog2ServerHost(config.getString("logging.remote.server"))
gelf.setUseLoggerName(true)
gelf.setUseThreadName(true)
gelf.setUseMarker(true)
gelf.setIncludeFullMDC(true)
gelf.setContext(ctx)
gelf.start()
LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)
.asInstanceOf[ch.qos.logback.classic.Logger]
.addAppender(gelf)
}