Skip to content

Working with Log Drains

Log Drains collect all of your logs using a service specializing in storing app logs. Learn how to use them with Vercel Integrations here.

Inspecting logs for the Build Step, Runtime, and Edge Network traffic of deployments is important in understanding the behavior of your application.

Log drains allow you to centralize log data from your applications, which makes it easier to debug, monitor, and analyze. Once a new log line is created, these logs can then be forwarded to archival, search, and alerting services via HTTPS, HTTP, TLS, and TCP.

Log drains on Vercel enable you to:

  • Have persisted storage of logs
  • Have a large volume of log storage available
  • Provide the ability to create alerts based on logging patterns
  • Generate metrics and graphs from logs data

You can add log drains in two ways:

Configurable log drains are available in Beta on Pro and Enterprise plans

Teams on Pro and Enterprise plans can subscribe to log drains that are generic and configurable from the Vercel dashboard without creating an integration. This allows you to use a HTTP service to receive logs via Vercel's log drains.

From the Vercel dashboard, go to Team Settings > Log Drains.

Select one or more sources to collect log drains.

The log data is typically collected from various sources, which will be forwarded to your webhook over a network connection. Make sure you select one of these sources when you add a new log drain:

  • Static: Collect logs for static assets like HTML and CSS files
  • Edge: Outputs log data from Edge Functions like Middleware
  • Lambda: Outputs log data from Vercel Functions like API Routes
  • External: Collect log results for external rewrites to a different domain
  • Build: Outputs log data from the Build Step

Select the delivery format for the collected log drains.

Select the mode that decides the format in which your log data gets delivered. You can to choose from the following format types:

  • JSON: With the JSON format, the URL receives a HTTPS or HTTP request with a JSON array on the POST body.
  • NDJSON: With the Newline Delimited JSON (NDJSON) format, the URL receives a HTTPS or HTTP POST request with JSON objects delimited by newline (\\n) on the HTTP POST body.
Note: Vercel supports three formats of Log drains. You can read and learn more about these here.

Choose the scope of project(s) to collect log drains.

After deciding the format, choose the scope of team projects for which logs will be collected. You can do it for all or some specific projects based on your requirements.

Choose the target branch and/or environment to collect log drains.

You can optionally configure the target branch and environment (preview or production) type to filter log results. This option is disabled by default, but you can toggle it to get customized filtered results based on your selection.

Define the endpoint URL for the log drains.

The log drains endpoint, which acts as the destination for your logs. All logs data will be forwarded to this URL as a POST request. Once added, Vercel asks you to "Verify" the endpoint. The purpose is to validate the URL ownership that responds with a status code 200 with a header. For example:

x-vercel-verify: f20eab3717014bdb9e7b9876789ea974c46bce5ce

If you are unable to complete the endpoint verification step, it's recommended to contact Vercel support team.

Note: The verification code is different for each team.

Add custom headers to protect your endpoint URLs.

You can optionally add up to 5 custom headers to your log drains URL because most of the log providers require an auth header (i.e., Authorization: Bearer[TOKEN] ) and/or additional metadata sent as header (i.e., target dataset). This feature helps send API keys to additional meta information to the receiver.

Once you have set up the log drains and specified the endpoint URL, click the "Add Log Drain" button, and Vercel will start sending logs to the log drain whenever your application generates them.

You can also click the "Test Log Drain" button to trigger a sample log (corresponding to the selected source(s)) to the target endpoint, so you can ensure the configuration is correct even before adding the log drain.

View all your new and existing configured log drains in a list view.

After the endpoint is confirmed and successfully verified, the logs will start to flow and appear in your Custom log drains list. While in beta, you can create and use up to 5 custom log drains at one time.

To remove an existing log drain, go to the Custom Log Drains list and click Delete from the context menu. All logs that are configured to your website will be removed, and the log drain no longer exists.

You can also integrate the log drains with third-party logging services. The Integrations Marketplace has numerous logging services for you to integrate.

To do so, you can:

  • Install the desired integration from the Integrations Marketplace
  • Follow the configuration steps provided and choose a project to connect with the service
  • Watch your logs appear on the selected service

You can easily collect and forward your deployment logs to a third-party logging provider and act accordingly with log drains.

Once integrated, you can view and manage all these logging services under the Integration Log Drains list. You can also find the Integration log drains in your list of integrations.

List of integrated third-party logging tools and services.

Note: Learn more about log drains and how to secure them by reading detailed documentation here.