grails如何配置log4j记录到tomcat日志

发布于 2024-11-19 00:27:14 字数 456 浏览 0 评论 0原文

每次我使用 Tomcat6 服务器上的生产环境启动 Grails 应用程序时,我都会在 /var/log/tomcat6/catalina.out 中看到以下错误:

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

我推测这是因为 log4j 正在尝试创建日志文件,并且没有所需的权限。

理想情况下,我希望应用程序的日志文件转到现有的 tomcat 日志 (/var/log/tomcat6/catalina.out) 或转到 /var/log/tomcat6 目录中的单独文件。

如何使用尽可能少的配置来更改 log4j 日志的位置?即我不想用它自己的输出模式定义一个完整的附加程序,我只想更改日志文件的位置。

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 required 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凹づ凸ル 2024-11-26 00:27:14

您可以通过在grails-app/conf/Config.groovy中配置它来设置日志记录以使用文件:

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

在这种情况下,所有级别为info及以上的日志事件都将被推送到文件 /var/log/tomcat6/mylog.log 和 stdout(tomcat 会自己添加到 catalina.out

请参阅:http://grails.org/doc/latest/guide/ 3.%20Configuration.html#3.1.2%20日志记录

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文