title: How to define a variable in Logback with a default value and override it?
body: <p>I would like to define a property/variable in Logback (1.2.1) that:</p>
  
  <ul>
  <li>Has a default value</li>
  <li>Can be overriden via a Java command-line option</li>
  </ul>
  
  <p>Basically, during development, I would like Maven to be invoking the <code>maven-surefire-plugin</code> with something like this:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
      &lt;configuration&gt;
          &lt;systemPropertyVariables&gt;
              &lt;log.dir&gt;${project.build.directory}/logs&lt;/log.dir&gt;
          &lt;/systemPropertyVariables&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>(I am sure that the above is working fine, because I have other properties being passed in for the tests this way and those work as expected).</p>
  
  <p>At the moment, I have the following <code>logback.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE configuration&gt;
  &lt;configuration scan="true" scanPeriod="30 seconds" debug="false"&gt;
  
      &lt;property name="log.dir" value="."/&gt;
  
      &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;${log.dir}/logs/my.log&lt;/file&gt;
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"&gt;
              &lt;fileNamePattern&gt;strongbox_%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
  
              &lt;fileNamePattern&gt;strongbox-%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
              &lt;maxFileSize&gt;128MB&lt;/maxFileSize&gt;
              &lt;maxHistory&gt;31&lt;/maxHistory&gt;
              &lt;totalSizeCap&gt;1GB&lt;/totalSizeCap&gt;
  
              &lt;maxHistory&gt;30&lt;/maxHistory&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;encoder&gt;
              &lt;charset&gt;UTF-8&lt;/charset&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS dd-MM-yyyy} | %-5.5p | %-20.20t | %-50.50logger{50} | %m%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
      ...
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The <code>-Dlog.dir=foo/logs</code>, it is simply being ignored and the log file is being produced in the current directory. What am I doing wrong here? Does it need a scope? Does it need an <code>if</code> condition to be set up?</p>