Logging is an essential aspect of monitoring and debugging applications deployed on serverless platforms like Vercel. Vercel provides built-in logging capabilities but with the huge caveat (for my application anyway) that they expire after 1 hour.
So I needed a third party solution (one which was preferably free as I’m a cheapskate) and I stumbled on Better Stack (previously Logtail). Better Stack is a powerful log management tool, which allows you to gain deeper insights into your application’s behaviour. In this post, I’ll explore simple process to capture Vercel logs using Better Stack for effective monitoring and troubleshooting.
Before we dive into the integration process, make sure you have the following:
- A Vercel account with a deployed project.
- A Better Stack account. If you don’t have one, sign up for free on Better Stack’s website.
Setting Up Better Stack
This could not be easier due to Vercel’s marketplace full of third-party services which you can integrate with. Luckily for us, Better Stack has an integration, meaning this process is extremely straight forward.
- Head to your Vercel project (The one which you want to capture the logs for) and head to the settings tab.
- Under the settings tab, you will see an “Integrations” option on the left hand side. Press this and you will be greeted with the following screen…
- Browse the marketplace searching for “Better Stack”. Once you have found it, click into it and hit the “Add Integration” button in the top right of the screen
- You will be greeted with a modal asking you to select a Vercel account to add the integration to. Choose the one that contains the project that you are wanting to capture the logs for.
- Next you will be asked which project you want to add the integration to. You can choose one particular project or add it to all of you r projects. For me I just needed it on the one, so I selected that from the dropdown. The finalise everytion and click “Add Integration”.
- Next you will get a modal that is asking you to connect Vercel to your Better Stack account. Click the button and everything should be set up and good to go
Verify Log Integration
To ensure that logs are being captured by Better Stack, follow these steps:
- Trigger some events in your Vercel application that generate logs.
Check Better Stack Dashboard:
- Return to the Better Stack dashboard.
- Navigate to your source (“VercelLogs”) to view incoming logs.
Better Stack offers various advanced features to enhance your logging experience. Consider exploring:
- Better Staack Queries: Construct queries to filter and analyze logs effectively.
- Alerts and Notifications: Set up alerts based on specific log events.
Capturing Vercel logs with Better Stack provides a centralized and efficient way to monitor and troubleshoot your applications. By integrating Better Stack into your Vercel project, you gain valuable insights that can help you identify issues, improve performance, and ensure a seamless user experience. Take advantage of the powerful features Better Stack offers to optimize your log management process. Happy logging!