How to Forward Logs

Functions are blocks of code that run on demand without the need to manage any infrastructure. Develop on your local machine, test your code from the command line (using doctl), then deploy to a production namespace or App Platform — no servers required. Learn more about functions.

You can configure functions to forward console and error logs from the function to a third-party logging service. Functions supports Papertrail, Datadog, and Logtail.

To configure your function to ship logs to a third party, you need to define a LOG_DESTINATIONS environment variable for it. This environment variable goes in your project.yml file and contains a JSON string with details on the log forwarding destination.

The JSON string is a JSON version of the log_destinations field of App Platform’s App Spec YAML file. You may use the App Spec reference for more details on the configuration required.

In App Platform, you configure Papertrail using a syslog endpoint. Functions requires an HTTP source token when using Papertrail.


The following examples show how to configure the LOG_DESTINATIONS environment variable in your project.yml file. The LOG_DESTINATIONS line belongs under an environment: key at whichever scope is appropriate for your situation: project, package, or function. See the project.yml reference for more information about scopes and setting environment variables.


For Papertrail, create an HTTP source and use the token in your configuration:



For Datadog, the configuration requires an endpoint URL and an API key:



For Logtail, create an HTTP source and use the resulting token for the configuration:


Multiple Destinations

The LOG_DESTINATIONS JSON structure is a list, so you can configure multiple log destinations: