Rails:无法访问日志文件 [英] Rails: Unable to access log file
问题描述
重新启动Rails应用程序时出现以下错误.我以前在另一台带有其他应用程序的服务器上遇到过此问题,但是不记得是什么问题了,或者我是怎么解决的.
I get the following error when restarting my rails app. I've had this problem before, on another server with another app, but can't remember what the problem was, or how I solved it.
Rails Error: Unable to access log file. Please ensure that /apps/staging/releases/20090310162127/log/staging.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
我正在Ubuntu上使用capistrano部署到一个杂种集群.
I'm deploying to a mongrel cluster with capistrano on Ubuntu.
当我做ls -l /apps/staging/releases/20090310162127/log/staging.log
结果是:
-rw-rw-rw- 1 me grp 51 Mar 10 16:07 /apps/staging/releases/20090310162127/log/staging.log
日志目录是/apps/staging/shared/log的link
.
The log dir is a link
to /apps/staging/shared/log.
这是怎么回事?
推荐答案
原来是一个细微的错误:
It turned out to be a subtle rails bug:
在这两行中引发异常时
logger = ActiveSupport::BufferedLogger.new(configuration.log_path)
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)
rails假定找不到日志文件.但是,实际错误发生在第二行:NameError,因为常量不正确.原因是我的配置文件中存在旧日志级别:
rails assumes it can't find the log file. However, the actual error occurred in the second line: a NameError because the constant is incorrect. The reason is that there was a legacy log level in my configuration file:
config.log_level = Logger::INFO
Rails 2.2使用其自己的记录器,并且不理解上述内容.
Rails 2.2 uses its own logger, and doesn't understand the above line.
解决方案:删除行,或使用:
Solution: remove line, or use:
config.log_level = :info
这篇关于Rails:无法访问日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!