开发者

Grails log4J Logging question on linux

I h开发者_运维问答ave been very frustrated about this.

I am trying to do the following:

  • Log all application related logs in application.log that are INFO or above
  • Understand what controls the configuration for catalina.out
  • Log only WARN to catalina.out

I am running my server on ubuntu and I have the default configuration for tomcat which includes a conf directory with a logging.properties. I renamed this file to l.p so it wouldn't conflict. (Not sure if this is a good idea)

In my config file, I have:

def catalinaBase = System.properties.getProperty('catalina.base')
if (!catalinaBase) catalinaBase = '.'   // just in case
def logDirectory = "${catalinaBase}${File.separator}logs"
println "Log Directory: ${logDirectory}"

log4j = {

  appenders {
    rollingFile name: 'applog', file: "${logDirectory}${File.separator}application.log", layout: pattern(conversionPattern: '%d{dd-MM-yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n'), maxFileSize: 1024
  }

  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',
          'net.sf.ehcache.hibernate'

  warn 'org.mortbay.log'

  info applog: 'grails.app'
  root {
   info 'applog'
  }

}

As a result, I am getting three logs:

catalina.2011-01-17.log  catalina.out  localhost.2011-01-17.log

The catalina.out has the following output:

Log Directory: /var/lib/tomcat6/logs
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.PropertyUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
log4j:ERROR WARNING: Exception occured configuring log4j logging: Cannot invoke org.apache.log4j.FileAppender.setFile - argument type mismatch

I do NOT see the application.log in the log file directory. Any help would be appreciated I am really frustrated about this.

One more thing, in windows everything come out to the console and the application.log is created in the .grails\1.3.5\projects\<appnmae>\tomcat directory


Your problem is obviously that there's a type mismatch. Specifically, log4j is expecting a String when you're giving it a GString. Try replacing:

"${logDirectory}${File.separator}application.log"

With this:

"${logDirectory}${File.separator}application.log".toString()

EDIT: Please read this BUG

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜