Better Stack Pino transport
Start logging in 3 steps
1. Install
Install the @logtail/pino npm package:
2. Set up
Set up the Pino logger with the Better Stack transport:
3. Start logging
Use the Pino logger as usual:
You should see your logs in Better Stack → Live tail.
Pino 7.0.0 or higher is required
The @logtail/pino transport supports Pino v7 and above.
Custom log levels
Pino lets you define your own levels with its customLevels option. On Pino 8.21 and newer, those levels reach Better Stack under their own names. On older versions, a custom number falls back to the nearest default level, so pass the same levels to the transport's customLevels option to keep their names:
The transport's customLevels option also accepts a comma-separated string, "notice:35,critical:55", and takes precedence over the names Pino reports, so you can send different names to Better Stack than the ones you use in your code.
Logging from serverless functions
The Pino transport sends logs from a worker thread, which serverless platforms like AWS Lambda freeze as soon as your handler returns. Its last logs may never reach Better Stack.
In serverless functions, use LogtailStream instead and flush the logs before the handler returns:
LogtailStream requires @logtail/pino 0.5.12 or newer.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏
Additional resources
Want to learn more about Pino log levels and adding contextual data to your logs?
Check out our Complete Guide to Pino Logging in Node.js.