Cloud Foundry

Introduction

Cloud Foundry is a Platform-as-a-Service for deploying and scaling applications.

Setup

Create a Papertrail account (free)

If you don’t already have an account, sign up (free).

Register app with Papertrail

  1. Visit Add Systems: Less common setup methods and choose option B, I use Cloud Foundry.
  2. Fill in the form. Papertrail will provide a log destination to use with a Cloud Foundry log drain for your app. If you have multiple Cloud Foundry apps, register each app separately.

Set up Cloud Foundry drain

Add the Papertrail drain destination:

$ cf cups my-logs -l syslog-tls://logsN.papertrailapp.com:XXXXX

replacing logsN and XXXXX with the name and port number from the log destination created in the previous step.

Bind the service

Bind the newly created service drain to the app:

$ cf bind-service <appname> my-logs

replacing <appname> with the name of the application.

Apply the changes

Restart the application to start sending log data to Papertrail:

$ cf restart <appname>

replacing <appname> with the name of the application.

Wait 30 seconds for logging to start. Once it starts, messages should appear in Papertrail’s Event viewer in realtime.

Notes

Recent versions of Cloud Foundry

Older versions of Cloud Foundry’s loggregator required the manual setup above, because otherwise, the sender name (hostname) would always appear as loggregator, and it was difficult to distinguish apps from each other.

Newer versions of loggregator (since v77) use “app, org and space name” for the hostname. If the Cloud Foundry provider in use has a recent version of loggregator, the manual setup above may not be necessary. Instead, follow the steps above using a typical Papertrail Log destination.

Unicorn

If you have added unicorn to your Cloud Foundry app stack, Papertrail’s Unicorn logging explanation may be useful.