Install the errsole, errsole-sequelize, and mariadb modules using the npm install command:
npm install errsole errsole-sequelize mariadb
const errsole = require('errsole');
const ErrsoleSequelize = require('errsole-sequelize');
// or using ESM
// import errsole from 'errsole';
// import ErrsoleSequelize from 'errsole-sequelize';
// Insert the Errsole code snippet at the beginning of your app's main file
errsole.initialize({
storage: new ErrsoleSequelize({
dialect: 'mariadb', // This specifies that you are using MariaDB
host: 'mariadb-host', // Replace with your actual MariaDB host
username: 'database-username', // Replace with your actual MariaDB username
password: 'database-password', // Replace with your actual MariaDB password
database: 'database-name' // Replace with the name of your MariaDB database
})
});
const express = require('express');
const errsole = require('errsole');
const ErrsoleSequelize = require('errsole-sequelize');
// Insert the Errsole code snippet at the beginning of your app's main file
errsole.initialize({
storage: new ErrsoleSequelize({
dialect: 'mariadb',
host: 'localhost',
username: 'root',
password: 'password',
database: 'dbname'
})
});
const app = express();
app.get('/', function (req, res) {
res.send('Hello World');
});
app.listen(3000);
Option | Type | Description |
---|---|---|
storage | ErrsoleSequelize | Required. Setup MariaDB as the storage backend with connection details. |
collectLogs | Array of Strings | Optional. The default value is ['error', 'info']. By default, Errsole collects both error and info logs. If you wish to limit Errsole to collecting only error logs, you can set this option to ['error']. If you prefer Errsole not to collect any logs, simply set this option to an empty array, []. |
enableConsoleOutput | Boolean | Optional. The default value is true. Control whether log output is also shown in the console. |
exitOnException | Boolean | Optional. The default value is true. By default, Errsole will exit the process after capturing an uncaught exception. If this is not the behavior you want, you can disable it by setting exitOnException to false. |
enableDashboard | Boolean | Optional. The default value is true. Enable or disable the web dashboard feature. |
port | Number | Optional. The default value is 8001. Specify the network port for the web dashboard. |
path | String | Optional. The default value is '/'. Define the base path for accessing the web dashboard. |
appName | String | Optional. The default value is the name from package.json. Specify the name of the app. |
environmentName | String | Optional. The default value is process.env.NODE_ENV. Specify the deployment environment. |
serverName | String | Optional. The default value is the hostname of the machine. Specify the name of the server. |
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/
. - Remote Server: If you have deployed Errsole on a remote server, use the server's IP address or domain name followed by the port number (e.g., YourServerIP:8001 or YourDomain:8001).
If you initialized Errsole with a different port or specified a custom path, adjust the URL as follows:
- Replace 8001 with your chosen port number.
- Append your custom path to the end of the URL.
http(s)://YourServerIP:CustomPort/YourCustomPath
If you encounter issues accessing port 8001 due to firewall restrictions, or if you prefer to host the Errsole Web Dashboard on your primary domain/port, you can configure the Errsole Proxy Middleware in your app. Here is a step-by-step guide: Proxy Middleware Configuration