Streaming App Logs to Log Management Services

Page last updated:

This topic describes how to drain logs from Cloud Foundry to a third-party log management service.

Cloud Foundry aggregates logs for all instances of your apps as well as for requests made to your apps through internal components of Cloud Foundry. For example, when the Cloud Foundry Router forwards a request to an app, the Router records that event in the log stream for that app. Run the following command to access the log stream for an app in the terminal:

$ cf logs YOUR-APP-NAME

If you want more than the limited amount of logging information that Cloud Foundry can buffer to persist, drain these logs to a log management service.

Feature: Since CAPI release 1.143.0, you can use mTLS inside your syslog drain. Follow the procedure in Step 2: Create and Bind a User-Provided Service Instance. Include the corresponding credentials as a PEM-encoded X.509 certificate.

For more information about the systems responsible for log aggregation and streaming in Cloud Foundry, see App Logging in Cloud Foundry.

Using services from the Cloud Foundry Marketplace

Your Cloud Foundry marketplace offers one or more log management services. To use one of these services, create an instance of the service and bind it to your app with the following commands:

$ cf bind-service YOUR-APP YOUR-LOG-STORE

For more information about service instance lifecycle management, see Managing Service Instances.

Note: Not all marketplace services support syslog drains. Some services implement an integration with Cloud Foundry that enables automated streaming of app syslogs. If you are interested in building services for Cloud Foundry and making them available to end users, see Services.

Using services not available in your marketplace

If a compatible log management service is not available in your Cloud Foundry marketplace, you can use user-provided service instances to stream app logs to a service of your choice. For more information, see the Stream App Logs to a Service section of the User-Provided Service Instances topic.

You might need to prepare your log management service to receive app logs from Cloud Foundry. For specific instructions for several popular services, see Service-Specific Instructions for Streaming App Logs. If you cannot find instructions for your service, follow the generic instructions.

Step 1: Configure the log management service

To set up a communication channel between the log management service and your Cloud Foundry deployment:

  1. Obtain the external IP addresses that your Cloud Foundry administrator assigns to outbound traffic.

  2. Provide these IP addresses to the log management service. The specific steps to configure a third-party log management service depend on the service.

  3. Add these IP addresses to your allow list to ensure unrestricted log routing to your log management service.

  4. Record the syslog URL provided by the third-party service. Third-party services typically provide a syslog URL to use as an endpoint for incoming log data. You use this syslog URL in Step 2: Create a User-Provided Service Instance.

    Cloud Foundry uses the syslog URL to route messages to the service. The syslog URL has a scheme of syslog, syslog-tls, or https, and can include a port number. For example:


Note: If the URL is an IP address, then it must not contain any leading zeros, for example, If you include the leading zeros, then URL parsing fails.

Step 2: Create and bind a user-provided service instance

You can create a syslog drain service and bind apps to it using Cloud Foundry Command Line Interface (cf CLI) commands.

  1. To create the service instance, run cf create-user-provided-service (or cf cups) with the -l flag.

    $ cf create-user-provided-service DRAIN-NAME -l SYSLOG-URL


In case of the usage of the mTLS feature delivered in CAPI release 1.143.0, you can use -p flag to define the client certificate and key as credentials, filling in values as follows.

$ cf create-user-provided-service DRAIN-NAME -l SYSLOG-URL -p '{"cert":"-----BEGIN CERTIFICATE-----\nMIIH...-----END CERTIFICATE-----","key":"-----BEGIN PRIVATE KEY-----\nMIIE...-----END PRIVATE KEY-----"}'

You can also provide a single certificate authority without client certificate and key if you are using a server certificate signed by your private CA.

$ cf create-user-provided-service DRAIN-NAME -l SYSLOG-URL -p '{"ca":"-----BEGIN CERTIFICATE-----\nMIIH...-----END CERTIFICATE-----"}'

Finally, a combination of the approaches described above uses a certificate authority for a server certificate signed by your private ca and a client certificate and key.

$ cf create-user-provided-service DRAIN-NAME -l SYSLOG-URL -p '{"ca":"-----BEGIN CERTIFICATE-----\nMIIH...-----END CERTIFICATE-----", "cert":"-----BEGIN CERTIFICATE-----\nMIIH...-----END CERTIFICATE-----","key":"-----BEGIN PRIVATE KEY-----\nMIIE...-----END PRIVATE KEY-----"}'

For more information, see [User-Provided Service Instances](./user-provided.html).
  1. To bind an app to the service instance, do one of the following:

    • Run cf push with a manifest. The services block in the manifest must specify the service instance that you want to bind.
    • Run cf bind-service:

      cf bind-service YOUR-APP-NAME DRAIN-NAME

After a short delay, logs start to flow.

For more information, see Managing Service Instances with the CLI.

Step 3: Verify logs are draining

To verify that logs are draining correctly to a third-party log management service:

  1. Take actions that produce log messages, such as making requests of your app.

  2. Compare the logs displayed in the CLI against those displayed by the log management service.

For example, if your app serves web pages, you can send HTTP requests to the app. In Cloud Foundry, these generate Router log messages, which you can view in the CLI. Your third-party log management service must display corresponding messages.

Note: For security reasons, Cloud Foundry apps do not respond to ping. You cannot use ping to generate log entries.

Create a pull request or raise an issue on the source for this page in GitHub