Heroku only keeps the most recent 1,500 lines of logs from our application. As we scale up and add more dynos, this will only cover a very brief time period. Heroku allows us to set up log drains, which allow us to stream our logs to another service for storage. Setting up log draining is a must-have for any production application. Having our log history easily searchable will be critical when debugging our application. In this recipe, we'll learn how to set up PaperTrail to store our Heroku logs.
To get started, let's fire up a terminal and navigate to one of our Heroku projects. Then, we can perform the following steps:
First, let's add PaperTrail to our application using Heroku add-ons. The default plan is free; as our application grows, we can add more storage if necessary:
$ heroku addons:add papertrail