Skip to content
Generic filters
Exact matches only

Papertrail Solution for Rails Applications on ElasticBeanstalk

Papertrail is an awesome log aggregation service we’ve used for long time. There are many ways to send logs to Papertail service, but we found the following solution is the most straightforward and secure for Rails apps like ours.

  • Add remote_syslog_logger to Gemfile

gem ‘remote_syslog_logger’

  • Configure logger in config/environments/production.rb

config.logger =“localhost”, 514, :program => ))

  • Create papertrail.config in .ebextensions folder with following content:

rsyslog-gnutls: []
mode: “000640”
owner: root
group: root
content: |
$ModLoad imudp
$UDPServerRun 514
mode: “000640”
owner: root
group: root
content: |
$DefaultNetstreamDriverCAFile /etc/papertrail-bundle.pem # trust these CAs
$ActionSendStreamDriver gtls # use gtls netstream driver
$ActionSendStreamDriverMode 1 # require TLS
$ActionSendStreamDriverAuthMode x509/name # authenticate by hostname
$ActionSendStreamDriverPermittedPeer *
command: cp ./.ebextensions/papertrail-bundle.pem /etc/papertrail-bundle.pem
command: /bin/echo “*.* @@${SYSLOG_HOST}” > /etc/rsyslog.d/03-papertrail.conf
command: “/sbin/service rsyslog restart”

  • Download the latest Papertrail certificate into .ebextensions folder

curl> .ebextensions/papertrail-bundle.pem

  • Configure SYSLOG_HOST environment variable for each deployment environment. If you use eb_deployer you can add a new option_settings such as:

– namespace: aws:elasticbeanstalk:application:environment
option_name: SYSLOG_HOST

  • Package, deploy and verify logs are sent to Papertrail

Basically the solution can be described as:

  • Rails app sending log directly to localhost rsyslog daemon using UDP protocol. UDP is a fire-and-forget protocol, so it helps improve logging performance.
  • Then syslog daemon forward logs to Papertrail syslog host using TCP with TLS encryption. Because production logs may have sensitive information we must deliver them through a reliable and secure channel.

sending logs


error: Content is protected !!