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 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 a log destination that accepts token-based authentication over HTTPS. This setting is under the Accept connections via… heading on Papertrail’s Create Log Destination page. Refer to Papertrail’s log destinations documentation for more details.
Use the provided 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:
LOG_DESTINATIONS JSON structure is a list, so you can configure multiple log destinations: