Skip to content

Instantly share code, notes, and snippets.

@atrepca atrepca/gist:7159195

Last active Jan 23, 2016
What would you like to do?
Send Heroku logs to an rsyslog server and save them to separate files by application
  • Add a Heroku drain for your app to forward the logs to your rsyslog server:

      heroku drains:add --app my-prod-app syslog://
  • List the drain you just created to get the unique Drain ID:

      heroku drains -x --app my-prod-app
  • On the rsyslog server save the logs coming from Heroku to separate files, without duplicating to /var/log/messages (thanks to the & ~). Create a /etc/rsyslog.d/90-heroku.conf file containing:

      if $HOSTNAME startswith 'Drain_ID' then /opt/log/heroku/my-prod-app.log
      & ~
  • Duplicate the above block for each log file, with & ~ on a separate line each time. Restart rsyslog when you're done and don't forget to set up logrotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.