Node.js version 12 or higher is required.
JavaScript quick start guide | Better Stack Documentation
Where do you want to collect your JavaScript logs from?
Logging from Node.js
Collect logs from the backend code of your application.
1. Install
Install Logtail Node NPM package:
Install Logtail Node
Copied!
2. Setup
Set up Logtail client:
3. Start logging 🎉
Send logs to Logtail
Copied!
You should see your logs in Better Stack → Live tail.
Logging from browser
Collect logs from your frontend code.
1. Install
Install Logtail Browser NPM package:
Install Logtail Browser
Copied!
2. Setup
Set up Logtail client:
Prefer using a Content Delivery Network?
Add Logtail import to your HTML page:
3. Start logging 🎉
Send logs to Logtail
Copied!
You should see your logs in Better Stack → Live tail.
Logging from browser and Node.js
Collect logs from both backend and frontend code of your Node.js application.
1. Install
Install Logtail JavaScript NPM package:
Install Logtail JS
Copied!
2. Setup
Set up Logtail client in backend and frontend code:
Backend code Frontend code
Copied!
3. Start logging 🎉
Log the same way in backend and frontend:
Send logs to Better Stack
Copied!
You should see your logs in Better Stack → Live tail.
Node.js version 12 or higher is required.
Need help?
Please let us know at hello@betterstack.com.
We're happy to help! 🙏
Additional information
Want to learning more about log levels and middleware in Node.js?
Continue to the Advanced usage of Better Stack JavaScript client.New to logging? See the Intro guide to Node.js logging and the Best practices for logging in Node.js.
Logging from browser? Some browsers (e.g. Brave, or some browser extensions) may block your logs from being sent. If you need to work around this issue, see possible workarounds on Github.
Using Bun runtime? No worries, our logging packages are tested in Bun as well as Node.
Using helper function for logging in Node.js? You can fix the logged
context.runtimeinfo by passingstackContextHintto the logger. See the usage in example project to learn more.
NPM packages
Package @logtail/js provides a convenient way to install and manage both @logtail/node and @logtail/browser NPM packages. You can install the packages separately if you wish to.