How to set up observability logging on Vercel
Set up observability logging on Vercel by enabling the built-in logging features in your project settings and optionally integrating third-party services like Datadog or New Relic. Configure runtime logging in your application code and use Vercel's Analytics dashboard to monitor performance metrics.
Prerequisites
- A Vercel account with a deployed project
- Access to your project's dashboard
- Basic understanding of logging concepts
- Node.js application (for runtime logging)
Step-by-Step Instructions
Access your Vercel project dashboard
Enable Function Logs
Configure Runtime Logging
console.log(), console.error(), or console.warn(). For more structured logging, install a logging library like Winston:npm install winstonThen implement structured logging in your functions:
import winston from 'winston';
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [new winston.transports.Console()]
});
export default function handler(req, res) {
logger.info('API request received', { method: req.method, url: req.url });
// Your function logic
}Set up Edge Config for Dynamic Logging
LOG_LEVEL and DEBUG_MODE. Connect this Edge Config to your project by going to Settings > Environment Variables and adding EDGE_CONFIG with your Edge Config URL.Enable Web Analytics and Speed Insights
npm install @vercel/analyticsAdd the Analytics component to your app:
import { Analytics } from '@vercel/analytics/react';
export default function App() {
return (
{/* Your app content */}
);
}Integrate Third-Party Observability Tools
Configure Log Drains (Enterprise)
Monitor and Access Logs
Common Issues & Troubleshooting
Function logs are not appearing in the dashboard
Ensure that Function Logs are enabled in your project settings. Check that your functions are actually executing and producing console output. Logs may take a few minutes to appear, and some plans have limited log retention.
Third-party integration is not receiving logs
Verify that all required environment variables and API keys are correctly configured. Check the integration status in Settings > Integrations and look for any error messages. Ensure your third-party service is properly configured to receive webhooks or API calls from Vercel.
Analytics data is missing or incomplete
Confirm that the @vercel/analytics package is installed and the <Analytics /> component is properly added to your application. Check that Web Analytics is enabled in your project settings and that your site has sufficient traffic (data appears with a delay of up to 24 hours).
Log drain connection fails
Verify that your destination endpoint is accessible and accepts the configured log format. Check that any required authentication tokens or API keys are valid. Test the endpoint independently and ensure it can handle the expected log volume from your Vercel deployments.