grails如何配置log4j记录到tomcat日志
每次我使用 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过在
grails-app/conf/Config.groovy
中配置它来设置日志记录以使用文件:在这种情况下,所有级别为
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
: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 tocatalina.out
by himself)See: http://grails.org/doc/latest/guide/3.%20Configuration.html#3.1.2%20Logging