title: How to output environment variable to Grails log4j log file
body: <p>I have the following file appender and I'm wanting the specific environment to be output to the log file whenever a message is logged: </p>
  
  <pre><code>appenders {
          rollingFile name:'mtagradepush_file', 
                      maxFileSize: 2048, 
                      file: "${globalDirs.logDirectory}${appName}.log".toString(), 
                      layout:pattern(conversionPattern: "[Env:${app.log.env}] %d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n")
  }
  </code></pre>
  
  <p>This conversion pattern worked when I used it in a log4j.properties file in a normal Java app, but now when using it with Grails it's not printing the value of the environment to the log file.</p>
  
  <p>The app.log.env variable is being set in CATALINA_OPTS when the Tomcat 6 server starts up, like this: </p>
  
  <blockquote>
    <p>export CATALINA_OPTS="-Xms128m -Xmx2000m -XX:MaxPermSize=512m
    -Dapp.log.env=DEVL..."</p>
  </blockquote>
  
  <p>If it's not possible to reference this variable then is there a way to grab the Grails environment variable?</p>