The oink logs command does not work on heroku

I recently started using the ock gem in my heroku application because I noticed a small memory leak with some controller actions. The oink logs command works fine locally, but I cannot define the command to make it work on my production site.

Here is the command I'm trying:

heroku run oink /log/* 

And here is the line from my production.rb file:

 config.middleware.use( Oink::Middleware, :logger => Rails.logger ) 

In my local installation, oink stores logs in the /log/oink.log file.

+6
source share
4 answers

Here's the answer: fooobar.com/questions/323877 / ...

It is important to use Hodel3000CompliantLogger instead of Rails.logger, otherwise oink will not be able to process the log files. It can also be configured not in config / environment / production.rb, but, for example, in config / initializers / oink.rb

 YourApplication::Application.middleware.use( Oink::Middleware, :logger => Hodel3000CompliantLogger.new(STDOUT), :instruments => :memory) 

This will write Oink to the default log file, which can later be captured

 heroku logs -n500 --app app_name > logfile_for_oink 

Either use another log management tool, such as PaperTrail, or set up syslog drainage (rsyslog on another * nix box).

Use oink with --threshold = 0 to show all entries

+2
source

Here is the answer from Heroku support:

"In most cases, using Oink locally is good enough to understand the problems of memory usage. Heroku's file system is ephemeral and each dyno has its own isolated file system, so it’s not very convenient to write and extract files. If you can configure Oink to write to stdout or on your rail log, its messages should appear in your Heroku logs, and you can use "log drain" or an archive backup add-on, such as Papertrail , to get a local copy of it. "

They seem to suggest using it in development. Or, if you can write to stdout and then write them yourself in the correct format.

I could not understand this as soon as possible, so in the end I used the heroku-api stone to automatically restart application servers every few hours from cron. This worked as a workaround.

+1
source

Try

 heroku run bundle exec oink log/* 
-1
source

To analyze production logs you need to run

 heroku run bundle exec oink log/production.log 
-1
source

Source: https://habr.com/ru/post/914392/


All Articles