I recently started using the oink gem on my heroku app because I noticed a small memory leak with some controller actions. The oink logs command works fine locally but I can't figure out the command to get it to work on my production site.
Here's the command I'm trying:
heroku run oink /log/*
And here's the line from my production.rb
file:
config.middleware.use( Oink::Middleware, :logger => Rails.logger )
On my local installation, oink is storing the logs in the /log/oink.log
file.
Here's the answer: https://stackoverflow.com/a/14145299/1684322
It is important to use Hodel3000CompliantLogger instead of Rails.logger otherwise oink will fail parsing logfiles. It may also be configured not in config/environments/production.rb but for example in config/initializers/oink.rb
YourApplication::Application.middleware.use( Oink::Middleware, :logger => Hodel3000CompliantLogger.new(STDOUT), :instruments => :memory)
This will make Oink write to default log file which may be later captured by
heroku logs -n500 --app app_name > logfile_for_oink
Or use other log management tool like PaperTrail , or set up syslog drain (rsyslog on another *nix box).
Use oink with --threshold=0 to show all entries
Here is a response from Heroku support:
"In most cases using Oink locally is good enough to understand memory usage issues. Heroku's filesystem is ephemeral and each dyno has its own isolated filesystem, so it's not very practical to write and fetch files. If you can configure Oink to write to stdout or your rails logger its messages should show up in your Heroku logs and you could use a log drain or a log archiving add-on like Papertrail to get a local copy of them."
So it sounds like they are suggesting to use it in development. Or if you can write to stdout and then log drain them yourself into the correct format.
I couldn't figure it out on short notice, so I ended up using the heroku-api
gem to automatically restart the app servers every few hours from cron job. This worked as a temporary fix.
Try
heroku run bundle exec oink log/*
To analyse your production logs you'll need to run
heroku run bundle exec oink log/production.log