Cloud Foundry

Intro

Cloud Foundry is a Platform-as-a-Service for deploying and scaling applications. Here’s how to aggregate logs from a Cloud Foundry app.

Setup

1. Create a Papertrail account (free)

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

2. Register app with Papertrail

Visit Add Systems: Less common setup methods. You’ll see a form with 3 choices. Choose option #2 (“I use Cloud Foundry”).

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.

3. Setup Cloud Foundry drain

Add the Papertrail drain destination:

cf cups my-logs -l syslog-tls://<host>.papertrailapp.com:XXXXX

replace <host>.papertrailapp.com and XXXXX with the name and port number from the log destination created in the previous step.

4. Bind the service

Bind the newly created service drain to the app:

cf bind-service <appname> my-logs

replace <appname> with the name of the application.

5. Apply the changes

Restart the application to start sending log data to Papertrail:

cf restart <appname>

replace <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

Unicorn

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