Best Node.js Logger for Your App: errsole
Tags: javascript, webdev, node
Published: 2024-05-30 11:17:46

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](https://github.com/errsole/errsole.js?tab=readme-ov-file#custom-logging-functions[](url)): Node.js Logger with a Built-in Dashboard

[errsole](https://github.com/errsole/errsole.js?tab=readme-ov-file#custom-logging-functions) 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);
```

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duoyhvdbfk21vt2xmjsq.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eejispdhngvryz375fhn.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3ird8tcapq0rkhgvxpu.png)

## 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.](https://github.com/errsole/errsole.js/tree/master)