DEV Community

Cover image for Best Node.js Logger for Your App: errsole
Saikumar
Saikumar

Posted on

Best Node.js Logger for Your App: errsole

Logging is a critical aspect of maintaining and debugging applications. In the Node.js ecosystem, several logging libraries have become popular due to their robust features and ease of use. In this blog, I'll introduce my logging library, errsole, and explain why it stands out as the best choice for your Node.js applications.

errsole: Node.js Logger with a Built-in Dashboard

errsole is an open-source logger for Node.js that offers a built-in web dashboard to view, filter, and search your app logs. Here are some key features of Errsole:

Features

  • Easy Setup: Simply insert the Errsole code snippet at the beginning of your app's main file.

  • Automated Log Collection: Collects all app logs directly from the Node.js console automatically.

  • Customized Logging: Provides multiple log levels and allows metadata inclusion with logs, plus custom alerts for specific log events.

  • Centralized Logging: Consolidates logs from multiple servers into one centralized database, with support for various database systems.

  • Interactive Web Dashboard: View, filter, and search logs easily.

  • Secure Access Control: Built-in authentication ensures only authorized access.

  • Error Notifications: Delivers notifications for app crashes and custom alerts via Email or Slack.

  • Data Retention: Allows specifying the number of days to keep logs.

Setup Options

errsole supports setup with multiple database systems, including SQLite, MongoDB, MySQL, PostgreSQL, MariaDB, and OracleDB. Access to the web dashboard can be configured for both local and remote environments.

Example Setup with MongoDB

In this blog, I will show an example of how to set up and access the web dashboard to view logs in the UI using MongoDB. To get started, you need to install the necessary packages:

npm install errsole errsole-mongodb

here is the express app...

const express = require('express');
const errsole = require('errsole');
const ErrsoleMongoDB = require('errsole-mongodb');

// Insert the Errsole code snippet at the beginning of your app's main file
errsole.initialize({
  storage: new ErrsoleMongoDB('mongodb://localhost:27017/', 'logs')
});

const app = express();

app.get('/', function (req, res) {
  res.send('Hello World');
});

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode

Web Dashboard Access

After completing the setup, you can access the Errsole Web Dashboard through the following methods:
Local Environment: Open your web browser and visit http://localhost:8001/.

Dashboard looks like...

Image description

Image description

Image description

Team Collaboration

You can invite your team to access the logs, making it easy to collaborate and troubleshoot issues together. For more details about Errsole, you can visit their GitHub repository: Errsole GitHub Repo.

Top comments (0)