Rails: Unable to Access Log File

Rails Error: Unable to access log file. Please ensure that /home.../log/development.log exists and is chmod 0666

Maybe just do what it asks you to do?:

$ touch the_required_path/development.log
$ chmod 0666 the_required_path/development.log

Docker and Rails: unable to access log file

Turns out the problem was because my log directory was mounted as the PostgreSQL log directory.

services:
postgres:
image: postgres:12.3-alpine
mem_limit: 64m
volumes:
- ./log:/root/log:cached # <-- this line was the culprit
- postgresql:/var/lib/postgresql/data:delegated
ports:
- "127.0.0.1:5432:5432"
environment:
PSQL_HISTFILE: /root/log/.psql_history
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
restart: on-failure
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 2s
retries: 10
logging:
driver: none

I describe the problem in more detail in this GitHub issue.

Rails: Unable to access log file

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

Ruby on Rails Setup: Unable to access log file

This issue is resolved now, though the the cause of the problem itself isn't entirely clear.

I had some weird configuration issues with Apache & Passenger (a.k.a. ModRails). Two modules existed: one that appeared to come packaged with Apache(?) and one I obtained via passenger-install-apache2-module. When I pointed to the pre-installed one, I had this logging issue. When I pointed to the one deployed by passenger-install-apache2-module, I had a completely different issue where Passenger would crash with a segfault (see my post on ServerFault here.)

In the end, I completely wiped my server and performed a clean install of everything from the base Ubuntu AMI (running on Amazon EC2 made this easy enough.) Upon reinstalling, I ran passenger-install-apache2-module and configured Apache to load the module deployed by it. This time, the module didn't crash, but the log error appeared. I set chmod 755 on the root of my Rails application, made sure the production.log existed and that it had at least chmod 0666 privileges. And voila, problem gone.

TL;DR Did a fresh install, made sure I was using the latest Passenger module, and my file permissions were set properly.

Can't access log files in production

I think you need to change the user and group of production.log to whatever user and group Rails (i.e. Passenger or Mongrel or whatever you are using) runs under.

Rails 3.2.6: Getting 'Unable to access log file' error for development.log file

I basically did what the error message suggested and did a chmod 0666 on the development.log file:

$> cd /Users/****/projects/rails_projects/rails_app/log/  
$> chmod 0666 development.log

Everything worked fine after that.

Rails Error: Unable to access log file And ActionView::Template::Error Permission denied

As Rails is suggesting in the error log, you should change permissions for the log file to 066:

chmod 0666 production.log

You are using root to deploy, but the web server is using another user name.



Related Topics



Leave a reply



Submit