Collect logs from your Go application.
Add slog-betterstack to your project dependencies using go get.
Configure slog-betterstack as a handler in a new slog logger.
Your log events will be sent to Better Stack automatically.
You should see your logs in Better Stack → Live tail.
The slog-betterstack library sends log events asynchronously to minimize impact on your application's performance. For short-lived applications (like CLI tools or one-off scripts), the program might exit before all logs are successfully dispatched.
To ensure all logs are sent before your application exits, consider adding a small delay (e.g., time.Sleep(time.Second * 5)) after your last log message. For long-running services (like web servers), this is generally not an issue as the process remains active.
Huge thanks to Samuel Berthe who maintains the slog-betterstack library as an MIT-licensed open-source! ❤️
You can use structured data in slog and send context along with your logs.
For more details check out the slog official documentation.
Please reach out to us at hello@betterstack.com.
We're happy to help! 🙏
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.