title: Logging configuration with file appenders and stdout in grails
body: <p>I have a configuration error in my grails application that's causing my appenders to send output to the wrong place, or not at all. There seem to be a number of questions regarding duplicate logging but I have been unable to apply any of the answers to my situation.</p>
  
  <p>Here is my logging config snippet:</p>
  
  <pre><code>log4j = {
  
          appenders {
                  // appender for usage tracking
                  appender new org.apache.log4j.RollingFileAppender(
                          name:"usageAppender",
                          maxFileSize:"1000KB",
                          maxBackupIndex: 10000,
                          file: "/var/log/tomcat6/app/usage.log",
                          layout:pattern(conversionPattern: '%d{DATE} %5p %c{1}:%L - %m%n')
                  )
                  appender new org.apache.log4j.RollingFileAppender(
                          name:"application",
                          maxFileSize:"1000KB",
                          maxBackupIndex: 10000,
                          file:"/var/log/tomcat6/app/application.log",
                          layout:pattern(conversionPattern: '%d{DATE} %8X{memoryused} %5p %t %c{1}:%L %X{username} %X{request} - %m%n')
                  )
                  console name:'stdout', layout:pattern(conversionPattern: '%d{DATE} %8X{memoryused} %5p %t %c{1}:%L %X{username} %X{request} - %m%n')
          }
          root {
                  // also tried error 'stdout'
                  error  'application'
          }
  
          error  'org.codehaus.groovy.grails.web.servlet',  //  controllers
                     'org.codehaus.groovy.grails.web.pages', //  GSP
                     'org.codehaus.groovy.grails.web.sitemesh', //  layouts
                     'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
                     'org.codehaus.groovy.grails.web.mapping', // URL mapping
                     'org.codehaus.groovy.grails.commons', // core / classloading
                     'org.codehaus.groovy.grails.plugins', // plugins
                     'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
                     'org.springframework',
                     'org.hibernate'
  
          info 'usageAppender':'usage.gui'
  }
  </code></pre>
  
  <p>When my program runs, output appears in <code>catalina.out</code>, in <code>usage.log</code> and in <code>application.log</code>. Output sent directly to stdout (bypassing log4j) appears in catalina.out</p>
  
  <p>If I set </p>
  
  <pre><code> info additivity: false 'usageAppender': 'usage.gui'
  </code></pre>
  
  <p>Then nothing is logged to either file appender, but stdout still goes into catalina.out (bypassing log4j).</p>
  
  <p>I would like the output from the 'usage.gui' logger to go to the <code>usage.log</code> file, output from all other logging to go to the <code>application.log</code> file, and all print statement output to go to  <code>catalina.out</code>. I don't want redundant logging. How do I configure this?</p>
  
  <p><em>UPDATE</em>
  In answer to @dmahapatro's question, logging in the application is done either with standard grails logging</p>
  
  <pre><code>log.trace('some event');
  </code></pre>
  
  <p>or with a custom logger created like this:</p>
  
  <pre><code>def usageLog
  public UsageService() {
      usageLog = Logger.getLogger("usage.gui")
  }
  </code></pre>
  
  <p>and used by calling this function:</p>
  
  <pre><code>protected void writeRecord(String topicId, String user, Long id, Long priorId, Long clientTime, String component, String action, String otherData) {
      String msg = "$topicId\t$user\t$id\t$priorId\t$clientTime\t$component\t$action\t$otherData"
      usageLog.info(msg)
  }
  </code></pre>