开发者

grails how to configure log4j to log to tomcat logs

Every time that I start up my grails application, using the production environment on my tomcat6 server I see the following error in /var/log/tomcat6/catalina.out:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: stacktrace.log (Permission denied)
...
...

I gather that this is becaues log4j is attempting to create a log file and doesn't have the r开发者_JAVA百科equired permissions.

Ideally I would like the log files for my application to go to either the existing tomcat log (/var/log/tomcat6/catalina.out) or to go to a separate file in the /var/log/tomcat6 directory.

How can I change the location of the log4j logs with the minimal amount of configuration possible? i.e. I don't want to define a complete appender with it's own output pattern, I just want to change the location of the log files.


You can setup logging to use file by configuring it in grails-app/conf/Config.groovy:

log4j = {
    appenders {
        file name:'file', file: '/var/log/tomcat6/mylog.log'
    }
    root {
        info 'stdout', 'file'
    }
}

at this case all log event with level info and above will be pushed into both file /var/log/tomcat6/mylog.log and stdout (that tomcat will add to catalina.out by himself)

See: http://grails.org/doc/latest/guide/3.%20Configuration.html#3.1.2%20Logging

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜