title: Java Logging Across Multiple Environments
body: <p>Our team is trying to get to a Single Build state; the build that's sent to Test is the same build that gets promoted to Staging->etc->Production. Right now setting up logging for different environments is a bit of a sticking point (currently we use Maven Profiles and filter the logger config at build time).</p>
  
  <p><strong>We have many web applications and I'd like the logging to be defined by the app and configurable by the environment it's deployed to.</strong></p>
  
  <p>We use Log4j though we're open to different implementations that could make this work. We'd like the app to be able to define the loggers as some apps may want specific logging on certain packages but, ultimately, I want the environment to be able to configure logging paths and levels. For example, the QA environment may typically have <code>INFO</code> level logging on the <code>com.foo.bar</code> package but, if they run into a sticky issue, they may wish to bump that up to <code>DEBUG</code>. I don't want to have the app redeployed since that technically changes the build.</p>
  
  <p>With minimal poking around I found that log4j can directly use system properties, so a setup like this would be possible:</p>
  
  <pre><code>&lt;appender name="someAppender" class="com.whatevs.SomeAppender"&gt;
      &lt;param name="File" value="${logger.path}/some_app.log"/&gt;
      &lt;!-- ... --&gt;
  &lt;/appender&gt;
  &lt;logger name="com.foo.bar"&gt;
      &lt;level value="${logger.level.com.foo.bar}"&gt;&lt;/level&gt;
  &lt;/logger&gt;
  &lt;root&gt;
      &lt;priority value="${logger.priority}"/&gt;
      &lt;appender-ref ref="someAppender"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>My concern is that as the number of apps deployed and number of loggers defined increases, the overhead of maintaining the system properties could become cumbersome:</p>
  
  <pre><code>-Dlogger.path=/var/log -Dlogger.priority=INFO -Dlogger.level.com.foo.bar=WARN ...
  </code></pre>
  
  <p>I'm sure this issue has been tackled before. What's the best way to go about it?</p>