Production log not working

2019-04-21 00:29发布

In the past I thought I was just crazy. I may be, but my production log is not at all responding to some requests. I am POSTing images to my rails app from a mobile client, then GETting a refreshed view in a web browser. The changed record is plainly visible. None of the above is showing up in my production log, but similar requests were logged an hour ago. I haven't changed any config files. I haven't restarted my server. Any suggestions as to why this is happening?

5条回答
在下西门庆
2楼-- · 2019-04-21 01:01

I solved the Problem by putting

Rails.logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).sync = true if Rails.logger

into my config/initializers/...

查看更多
萌系小妹纸
3楼-- · 2019-04-21 01:03

In my case first i added config.log_level = :debug to production.rb file then i had to create the production.log file (in the log folder), then giving appropriate permissions with chmod command.

查看更多
趁早两清
4楼-- · 2019-04-21 01:06

I had the same problem related to production log.

To trace back issue with web server:

tail -f /var/log/apache2/error.log

Message from application: Permission denied - /var/www/APPLICATION-NAME/log/invitation.log (Errno::EACCES)

cd /var/www/APPLICATION-NAME/log

using the comman ll you will get log permissions

total 28
drwxr-sr-x  2 www-data www-data 4096 Sep 18 03:55 ./
drwxrwsr-x 14 www-data www-data 4096 Sep 24 23:52 ../
-rw-r--r--  1 root     www-data   71 Sep 18 03:55 agent_invitation.log
-rwxrwxrwx  1 root     www-data   71 Sep 18 03:55 email.log*
-rw-r--r--  1 root     www-data   71 Sep 18 03:55 invitation.log
-rw-r--r--  1 root     www-data   71 Sep 18 03:55 messages.log
-rw-r--r--  1 root     www-data   51 Sep 13 01:32 production.log

Solution: Have to change owner from root to other user:

chown www-data:www-data ./ -R

Now use ll to see the permissions

total 28
drwxr-sr-x  2 www-data www-data 4096 Sep 18 03:55 ./
drwxrwsr-x 14 www-data www-data 4096 Sep 24 23:52 ../
-rw-r--r--  1 www-data www-data   71 Sep 18 03:55 agent_invitation.log
-rwxrwxrwx  1 www-data www-data   71 Sep 18 03:55 email.log*
-rw-r--r--  1 www-data www-data   71 Sep 18 03:55 invitation.log
-rw-r--r--  1 www-data www-data   71 Sep 18 03:55 messages.log
-rw-r--r--  1 www-data www-data   51 Sep 13 01:32 production.log

Restart you web server:

sudo service apache2 restart

now check production logs.

查看更多
Viruses.
5楼-- · 2019-04-21 01:18

Check what value is set to

config.log_level = :warn

in your

/rails_app/config/enviroments/production.rb

FYI

The available log levels are: :debug, :info, :warn, :error, :fatal.

So if you set the level to fatal only serious errors will be logged. If you set it to debug almost everything will be logged. By default in production it is set to warn. This is with good reason. As you don't want huge log files piling up on your production server for no reason.

查看更多
等我变得足够好
6楼-- · 2019-04-21 01:23

Low memory is the most likely cause that I have been able to come up with. I will post here if I can prove it.

查看更多
登录 后发表回答