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 through
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 not available on the Pro plan trial
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 through Vercel's log drains.
From the Vercel dashboard, go to Team Settings > 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 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
HTTPrequest with a JSON array on the
- NDJSON: With the Newline Delimited JSON (NDJSON) format, the URL receives a
HTTP POSTrequest with JSON objects delimited by newline (
\\n) on the
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.
The log drains endpoint acts as the destination for your logs and is provided by the provider ingesting the log drains. 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:
If you are unable to complete the endpoint verification step, it's recommended to contact Vercel support team.
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.
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 Log Drains Integration list. You can also find the log drains integration in your list of integrations.