Logging from an application on CloudFoundry

Share on:

Sending logs from an application on CloudFoundry to some logging service

In CloudFoundry by default app logs are included in syslog drains. So if syslog drain endpoint is provided to application the logs will be sent to that endpoint.

Assumptions/ Prerequisites

  1. You have cf cli installed on your machine.
  2. You have correct permissions to create user provided service on CloudFoundry

Steps to follow

Below is a very simple guide to send logs from an application running on CloudFoundry to a logging service for example logstash. What you need to do is create a user-provided service on CloudFoundry, and bind your app to this service.

  1. Create a user-provided service
1cf cups SERVICE_INSTANCE_NAME -l syslog://some.log-aggregator.url
  1. Bind your application to the above created service.
1cf bind-service APPLICATION_NAME SERVICE_INSTANCE_NAME
  1. To make this changes effective restage the application.
1cf restage APPLICATION_NAME

Login to you logging service and verify if the logs from application are visible there.