Rails:无法访问日志文件

发布于 2024-07-15 01:01:14 字数 660 浏览 8 评论 0原文

重新启动 Rails 应用程序时出现以下错误。 我以前在另一台服务器上使用另一个应用程序时遇到过这个问题,但不记得问题是什么,也不记得我是如何解决的。

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 部署到混合集群。

当我执行 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/ 的链接共享/日志。

这是怎么回事?

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.

I'm deploying to a mongrel cluster with capistrano on Ubuntu.

When I do ls -l /apps/staging/releases/20090310162127/log/staging.log

the result is:

-rw-rw-rw- 1 me grp 51 Mar 10 16:07 /apps/staging/releases/20090310162127/log/staging.log

The log dir is a link to /apps/staging/shared/log.

What's going on?

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

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

发布评论

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

评论(2

枫林﹌晚霞¤ 2024-07-22 01:01:15

Rails 是否以 me 身份运行? 如果不是,它以什么用户身份运行? 该用户是否被入狱了? 用户是否拥有 /apps/staging/shared/log 的所有组件以及 /apps/staging/releases/20090310162127/log 的所有组件的遍历权限?

Is Rails running as me? If not, what user is it running as? Is that user jail'ed? Does the user have traverse permissions for all components of /apps/staging/shared/log as well as all components of /apps/staging/releases/20090310162127/log?

知你几分 2024-07-22 01:01:14

事实证明这是一个微妙的 Rails 错误:

当这两行中引发异常时,

logger = ActiveSupport::BufferedLogger.new(configuration.log_path)
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)

rails 假设它找不到日志文件。 然而,实际错误发生在第二行:NameError,因为常量不正确。 原因是我的配置文件中有一个旧的日志级别:

config.log_level = Logger::INFO

Rails 2.2 使用自己的记录器,并且不理解上面的行。

解决办法:去掉线,或者使用:

config.log_level = :info

It turned out to be a subtle rails bug:

When an exception is raised in these two lines

logger = ActiveSupport::BufferedLogger.new(configuration.log_path)
logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase)

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 uses its own logger, and doesn't understand the above line.

Solution: remove line, or use:

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