Errsole is an open-source logging library for Node.js applications. It comes with a built-in log viewer to view, filter, and search your application logs. If you are SSHing into servers or scrolling through raw log files to find errors or debug logs, Errsole simplifies the process for you.
Quick Setup
In this guide, I set up Errsole with SQLite. SQLite stores data in a file, so your logs will be saved directly on your server—ideal for quick and simple setups.
Errsole supports multiple storage options for centralized logging. Explore all available options here.
1. Install the required modules
Run the following command to install Errsole and the SQLite storage module in your Node.js project:
npm install errsole errsole-sqlite
2. Configure the logger
Create a separate logger.js
file to initialize and export the Errsole logger, so you can use it across your project:
const errsole = require('errsole');
const ErrsoleSQLite = require('errsole-sqlite');
const os = require('os');
const path = require('path');
const logFile = path.join(os.tmpdir(), 'your-app-name.log.sqlite');
errsole.initialize({
storage: new ErrsoleSQLite(logFile),
appName: 'your-app-name'
});
module.exports = errsole;
Now, you can include this logger in any file using:
const errsole = require('./logger');
3. Use the logger in your application code
To start logging, include the logger in your application code. Here is an example using Express:
const express = require('express');
const errsole = require('./logger');
const app = express();
app.get('/', (req, res) => {
res.send('Hello World!');
});
const port = 3000;
app.listen(port, () => {
errsole.log(`Hello World app is listening on port ${port}`);
});
Accessing the Log Viewer
After completing the setup, start your application and access the Errsole Web Dashboard to view and manage your logs:
For Local Development
Visit http://localhost:8001/
For Remote Servers
Replace with your server IP or domain:
http://your-server-ip:8001/
http://your-domain:8001/
Optional: NGINX Configuration
If your application is behind NGINX, you can configure access to the Errsole Web Dashboard by adding the following lines to your NGINX configuration file:
location = /your-app-name/logs {
return 301 /your-app-name/logs/;
}
location /your-app-name/logs/ {
proxy_pass http://localhost:8001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
After updating the configuration, reload NGINX to apply the changes:
sudo nginx -s reload
You can now access the Errsole Web Dashboard through your domain:
- For server IP access:
http://your-server-ip/your-app-name/logs/
- For domain access (HTTP):
http://your-domain/your-app-name/logs/
- For domain access (HTTPS):
https://your-domain/your-app-name/logs/
Replace /your-app-name/logs
with your desired log path.
Conclusion
Errsole provides a fast and easy way to log and view errors in real time. While this guide uses SQLite for local logging, production environments can benefit from centralized logging using other supported storage backends.
Explore the full documentation here: https://github.com/errsole/errsole.js