[logback-user] Access Properties Defined in Logback programmatically

Charlie Hubbard charlie.hubbard at gmail.com
Fri Jan 11 22:43:22 CET 2013

I have an administration console I'm building, and I want to display the
logs created in Logback for my application. However, where those logs are
stored is different per environment. I have several property files that
define where the logs are stored:

  <property resource='log.properties'/>
  <property resource='log.${ENV:-prod}.properties'/>

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">

I'd like to find the value of ${log.dir} from Logback's Java API. I'd
tried the following, but it doesn't have any of the properties defined
in the resources. For example:

LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
 String logDir = loggerContext.getProperty("log.dir"); // this always
returns null

So my question is what API calls should I be using?



If you'd rather have the stackoverflow karma I originally posted this there:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130111/bab567bd/attachment.html>

More information about the Logback-user mailing list