开发者

Rails logging to Apache logs rather than application log

开发者 https://www.devze.com 2023-02-03 18:17 出处:网络
I am running a Rails application on Apache using mod_passenger. I would like Rails.logger calls to write to the Apache error log rather than to the application\'s log file in log/producti开发者_如何学

I am running a Rails application on Apache using mod_passenger. I would like Rails.logger calls to write to the Apache error log rather than to the application's log file in log/producti开发者_如何学运维on.log.

How can I do this?


In your config/environments/production.rb file you can add something like:

config.logger = Logger.new("/var/log/apache2/error.log")

Of course your app will need to have permissions to such a file. In addition intermixing Apache errors with your apps logs is definitely not a good idea.


This doesn't answer your question directly but I've just run a little test and STDERR.puts "meep" ended up in Apache's error log while using mod_passenger.

Perhaps then you could point config.logger at STDERR?

0

精彩评论

暂无评论...
验证码 换一张
取 消