New to logging? See the Intro guide to Node.js logging and the Best practices for logging in Node.js.
Not using Logtail yet? Check out the Quick start guide to install and set up the Logtail JavaScript client.
Get started with Logtail in your JavaScript application using this overview of the Logtail logger.
New to logging? See the Intro guide to Node.js logging and the Best practices for logging in Node.js.
Not using Logtail yet? Check out the Quick start guide to install and set up the Logtail JavaScript client.
Logtail JavaScript client instance provides 4 logging methods for the 4 default log levels. The log levels and their methods are:
debug()info()warn()error()To send a log message of selected log level, use the corresponding method. In this example, we send the DEBUG level log and ERROR level log:
The Logtail client automatically adds context to the logs.
The following JSON output is sent to Logtail:
Quickly troubleshoot your application by logging structured data. Pass an object as a second argument to any logging method, like in the example below:
This creates the following JSON output:
You can intercept every logged item and modify it before it's pushed to Logtail. This could be useful, for example, for adding the current user's ID to the log or for filtering:
If you're using Logtail in a TypeScript codebase, you can take advantage of our types. You could write the enriching middleware function with types like this:
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.