简体   繁体   English

部署 grails 应用程序时出现 stacktrace.log 问题

[英]problem with stacktrace.log while deploying grails app

i've problem with the deployment of an grails app.我在部署 grails 应用程序时遇到问题。

i get the following exception:我得到以下异常:

log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: stacktrace.log (Permission denied)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:177)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:102)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
    at org.apache.log4j.spi.OptionHandler$activateOptions.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at org.codehaus.groovy.grails.plugins.logging.Log4jConfig.createFullstackTraceAppender(Log4jConfig.groovy:177)
    at org.codehaus.groovy.grails.plugins.logging.Log4jConfig.this$2$createFullstackTraceAppender(Log4jConfig.groovy)
    at org.codehaus.groovy.grails.plugins.logging.Log4jConfig$this$2$createFullstackTraceAppender.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
    at org.codehaus.groovy.grails.plugins.logging.Log4jConfig.configure(Log4jConfig.groovy:145)
    at org.codehaus.groovy.grails.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:62)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 25, 2011 11:16:54 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext

my settings for the logger in the config look like this:我在配置中对记录器的设置如下所示:

log4j = { 
    appenders {
        rollingFile name: "stacktrace", maxFileSize: 1024, file: "/var/www/logs/myapp-stacktrace.log"
     }
 }

i also tried to disable the logger with log4j = { appenders { 'null' name: "stacktrace" } }我还尝试使用 log4j = { appenders { 'null' name: "stacktrace" } } 禁用记录器

the permission for this directory are set for the tomcat-user此目录的权限是为 tomcat-user 设置的

-rwxr--r-- 1 tomcat6 root 0 May 24 18:38 myapp-stacktrace.log

no success at all... thanks for any feedback and help!!根本没有成功...感谢任何反馈和帮助!

I ran into a similar issue with Grails 1.3.7 and found this fixed it (by pushing the stack trace log into the standard logging directory)我在 Grails 1.3.7 中遇到了类似的问题,并发现它已修复(通过将堆栈跟踪日志推送到标准日志记录目录)

log4j = {
    appenders {
    rollingFile name: "stacktrace", maxFileSize: 1024, file: "/var/logs/piws-stacktrace.log"
    ....

Check out the official documentation on deploying a Grails application to Tomcat at http://www.grails.org/Deployment/#Tomcat . Check out the official documentation on deploying a Grails application to Tomcat at http://www.grails.org/Deployment/#Tomcat .

To quote the relevant section...引用相关部分...

"Be aware that on default settings, Grails will attempt to write to the tomcat directory certain files, typically the stacktrace.log and the h2 database. Your Tomcat directory is likely installed with owner/group of root, while the Tomcat server runs as user tomcat6. This will cause your application to fail to start with write permission errors. Either change your Grails production settings so that these files are written elsewhere to directories with correct permissions OR change the owner of the Tomcat directory (for Unix: /var/lib/tomcat6) to tomcat6 (or whatever tomcat user you set up using the TOMCAT6_USER setting). " "Be aware that on default settings, Grails will attempt to write to the tomcat directory certain files, typically the stacktrace.log and the h2 database. Your Tomcat directory is likely installed with owner/group of root, while the Tomcat server runs as user tomcat6。这将导致您的应用程序无法启动并出现写权限错误。要么更改您的 Grails 生产设置,以便将这些文件写入其他位置具有正确权限的目录,要么更改 Tomcat 目录的所有者(对于 Z6F72E28063C30C7468FB6AF4653F4F9CZ 目录(对于 Z6F72E28063C30C7468FB6AF4653F4F9CZ) /tomcat6) 到 tomcat6(或您使用 TOMCAT6_USER 设置设置的任何 tomcat 用户)。 "

You can use sudo chown tomcat6 /var/lib/tomcat6 to change the owner (replace the user running tomcat and the directory where the logs are being written if needed), which is the simplest and most appropriate solution for most situations.您可以使用sudo chown tomcat6 /var/lib/tomcat6更改所有者(如果需要,替换运行 tomcat 的用户和正在写入日志的目录),这是大多数情况下最简单和最合适的解决方案。

check disk space (long shot) and try chmodding to 777 just to verify its a permission issue.检查磁盘空间(远射)并尝试 chmodding 到 777 只是为了验证它的权限问题。 If it is, you either not running tomcat as the tomcat user or your directories are off...如果是,您要么没有以 tomcat 用户身份运行 tomcat,要么您的目录已关闭...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM