I have installed phussion passenger on osx following this guide from apple. I also used the PassengerPane to configure it.
It works, but it doesn't write anything to development.log. It's not a permissions problem.
Do you have any idea why?
OK, I found it.
Logging wasn't working because of these lines in application.rb:
config.logger = Logger.new(STDOUT)
config.log_level = :info
These were required for using Heroku's logging, but not anymore.
Passenger runs on production by default. Check production.log, you should see content there.
Related
How to see the live server log in production like it is shown in development?
My app is on digitalOcean, if that helps. I am using unicorn as my production server.
When I do tail -f log/production.log, I can just see some migration info like this, but not the live requests info along with the SQL queries being run.
Also in my production.rb, I changed config.log_level to :debug
Try adding these lines of code into config/environments/production.rb:
Rails.logger = Logger.new(STDOUT)
config.logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")
Reference:
This article for more info on logger
I am using rails 4.2.6. And the log_level is :warn for production environment. But when I tail -f the production log file on server I am seeing that it logs at :info level. So the log file is getting bigger in a short time. I am really creazy. Is there any clue that how can I solve this issue?
I find the solution. The solution is this: config.action_view.logger = nil.
When I tail the logs and hit my app, I have heroku[router] telling me I received a 500, and the app shows the usual "We're sorry, but something went wrong" message... but there are no additional details from Rails in the logs to tell me what is causing the 500.
I've read a couple of other threads that asked about this but they mostly end with people suggesting to do a rake:db migrate which fixed the error but there's no further discussion about the logging unfortunately. (And yes I'm sure there's no pending migrations 😄)
I have the rails_12factor gem installed
I've tried setting config.log_level = :debug in production.rb
I've tried creating a config variable of LOG_LEVEL set to DEBUG (which should supersede the config setting)
I've set $stdout.sync = true in config.ru as suggested here
What am I missing?
As an aside, have tried re-producing my actual problem locally with a backup of the database being used with Heroku but I can't reproduce it, so I'm finally forced to get to the bottom of this logging problem.
I first just got this to work by manually adding:
config.logger = Logger.new(STDOUT)
to production.rb but that obscured the real issue...
RACK_ENV and RAILS_ENV were both set to staging while I had the gem loading in the :production set... So although Heroku told me it was using the rails_12factor gem when the instance started, it wasn't really (I assumed it wouldn't be listed there if it wasn't a production environment, wrong assumption!)
staging.rb was loading production.rb which is why setting STDOUT there worked, thus confusing the issue further.
Thanks for the replies, and hope this helps someone else in future - go check your config variables and/or change where the gem is being loaded! :)
Debugging errors on heorku can get difficult most of the time.
For people facing a similar problem I suggest using PaperTrail heroku add-on for logging, It is free upto a certain limit.
It is realtime and provides with searching of logs, events hooks, mailing alerts etc. facilities. You will never have trouble debugging errors on heroku.
You can simply install it using the heroku cli command.
heroku addons:create papertrail
I am building an application with Heroku and having some problems.
I want to debug some content like I do with rails server:
logger.debug '...'
How can I do that in Heroku, so I can see the debugging in heroku logs? (or anything else..)
Thanks!
Details here: http://devcenter.heroku.com/articles/logging
Also make sure you set the right Logging level for your Rails app:
http://blog.sethladd.com/2005/11/adjust-log-level-in-ruby-on-rails.html
The Cedar stack in Heroku does not appear to be responsive to the LOG_LEVEL config (env) variable that works for previous stacks (I use the logging:expanded addon). I tried setting LOG_LEVEL to both debug and DEBUG without success.
Only by setting config.log_level = :debug in config/environments/production.rb am I able to see the output of 'logger.debug'.
Been fighting with this for a long time, solution is nice and simple:
Set in production.rb instead of
config.log_level = :debug
place:
config.logger = Logger.new(STDOUT)
config.logger.level = Logger::DEBUG
and you get the full logging output.
heroku logs on your command line will give you the logs for the current app. If you have expanded logging turned on you can tail this output
Using Rails 3.2, we made this configurable by modifying config/environments/{environment}.rb to drive it from an environment variable:
config.log_level = ENV["LOG_LEVEL"].to_sym if ENV["LOG_LEVEL"]
Then, we can modify the Heroku config variable to change it:
heroku config:set LOG_LEVEL=debug --app <app name>
This lets us easily log more or less as needed.
This worked for me:
heroku config:set LOG_LEVEL=debug
To write to your logs on Heroku, instead of using logger.debug "..." simply use puts:
puts "..."
You don't even need to set the config.log_level setting in config/environments/production.rb.
See the docs here.
config.log_level = ENV['APP_LOG_LEVEL'] ? ENV['APP_LOG_LEVEL'].to_sym : :error
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/production.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?