Include PIDs in Rails production.log

Andre

03 Aug, 2011 11:08 PM UTC

My production servers run Nginx + Passenger, so there are multiple ruby processes all writing to production.log at any given time. This makes it impossible to untangle which lines belong to which request or process afterwards, so I wrote a logger class that inherits from ActiveSupport::BufferedLogger, but includes the severity and PID in the line that is written to the log. This means that in papertrail, I can easily filter the log by PID when I need to see what happened in a specific request or set of requests. Hopefully this will help someone else having the same problem. :)

https://gist.github.com/1091611

  1. Support Staff 1 Posted by Troy on 16 Aug, 2011 02:10 PM UTC

    This rocks, Andre. Nice work. The "traditional" solution - in as much as any can be traditional - is to have a per-worker log file, but I think appending the PID to entries is a lot easier.

    Thanks again for sending this. I'm closing the ticket but your update will still appear in other people's search results. Cheers,

    Troy

  2. This discussion is closed. Please email support@papertrailapp.com to continue troubleshooting this or a related problem.