<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: errsole</title>
    <description>The latest articles on Forem by errsole (@errsole).</description>
    <link>https://forem.com/errsole</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F6325%2Fcabc08fa-af2a-47b5-9988-834bebc77196.png</url>
      <title>Forem: errsole</title>
      <link>https://forem.com/errsole</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/errsole"/>
    <language>en</language>
    <item>
      <title>How to set up a Node.js Log Viewer: a step-by-step guide</title>
      <dc:creator>Venki</dc:creator>
      <pubDate>Tue, 08 Apr 2025 13:24:28 +0000</pubDate>
      <link>https://forem.com/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp</link>
      <guid>https://forem.com/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/2K2Mvqdcq70"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Setup
&lt;/h2&gt;

&lt;p&gt;This guide sets 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.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Errsole supports multiple storage options for centralized logging. Explore all available options &lt;a href="https://github.com/errsole/errsole.js?tab=readme-ov-file#setup" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1. Install the required modules
&lt;/h3&gt;

&lt;p&gt;Run the following command to install Errsole and the SQLite storage module in your Node.js project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;errsole errsole-sqlite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Configure the logger
&lt;/h3&gt;

&lt;p&gt;Create a separate &lt;code&gt;logger.js&lt;/code&gt; file to initialize and export the Errsole logger, so that you can use it across your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errsole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;errsole&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ErrsoleSQLite&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;errsole-sqlite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;os&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;os&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;logFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tmpdir&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-app-name.log.sqlite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;errsole&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ErrsoleSQLite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logFile&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;appName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-app-name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;errsole&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Replace &lt;strong&gt;your-app-name&lt;/strong&gt; with the actual name of your app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, you can include this logger in any file using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errsole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./logger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Use the logger in your application code
&lt;/h3&gt;

&lt;p&gt;To start logging, include the logger in your application code. Here is an example using Express:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errsole&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./logger&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;errsole&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Hello World app is listening on port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessing the Log Viewer
&lt;/h2&gt;

&lt;p&gt;After completing the setup, start your application and access the log viewer to view and manage your logs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Local Development&lt;/strong&gt;&lt;br&gt;
Visit &lt;code&gt;http://localhost:8001/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Remote Servers&lt;/strong&gt;&lt;br&gt;
Replace with your server IP or domain:&lt;br&gt;
&lt;code&gt;http://your-server-ip:8001/&lt;/code&gt;&lt;br&gt;
&lt;code&gt;http://your-domain:8001/&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Optional: NGINX Configuration
&lt;/h2&gt;

&lt;p&gt;If your application is behind NGINX, you can configure access to the log viewer by adding the following lines to your NGINX configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;/your-app-name/logs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kn"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;301&lt;/span&gt; &lt;span class="n"&gt;/your-app-name/logs/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/your-app-name/logs/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://localhost:8001/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_http_version&lt;/span&gt; &lt;span class="mf"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Upgrade&lt;/span&gt; &lt;span class="nv"&gt;$http_upgrade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Connection&lt;/span&gt; &lt;span class="s"&gt;"upgrade"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Replace &lt;strong&gt;/your-app-name/logs&lt;/strong&gt; and &lt;strong&gt;/your-app-name/logs/&lt;/strong&gt; with the desired URL path where you want the log viewer to be accessible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After updating the configuration, reload NGINX to apply the changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nginx &lt;span class="nt"&gt;-s&lt;/span&gt; reload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now access the log viewer through your domain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For server IP access: &lt;code&gt;http://your-server-ip/your-app-name/logs/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For domain access (HTTP): &lt;code&gt;http://your-domain/your-app-name/logs/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;For domain access (HTTPS): &lt;code&gt;https://your-domain/your-app-name/logs/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Replace &lt;strong&gt;/your-app-name/logs/&lt;/strong&gt; in the URLs above to match the path you configured in NGINX.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Explore the full documentation here: &lt;a href="https://github.com/errsole/errsole.js" rel="noopener noreferrer"&gt;https://github.com/errsole/errsole.js&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating a Custom Logger for a Node.js Application using Errsole</title>
      <dc:creator>Venki</dc:creator>
      <pubDate>Fri, 23 Aug 2024 13:25:34 +0000</pubDate>
      <link>https://forem.com/errsole/creating-a-custom-logger-for-a-nodejs-application-using-errsole-6bo</link>
      <guid>https://forem.com/errsole/creating-a-custom-logger-for-a-nodejs-application-using-errsole-6bo</guid>
      <description>&lt;p&gt;Every robust logging system consists of three key components: a Collector, a Storage, and a Visualizer. Popular Node.js logging modules like Winston and Pino function solely as log collectors. Errsole, however, offers a complete logging solution that includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Log Storage:&lt;/strong&gt; Save logs in a file or your application’s database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built-in Dashboard:&lt;/strong&gt; View, filter, and search logs using the built-in dashboard.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Alerts:&lt;/strong&gt; Receive real-time notifications for critical errors.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Installing Errsole and its dependencies
&lt;/h2&gt;

&lt;p&gt;To use Errsole, you need to install the Errsole module along with a storage module based on your chosen database. Here are the installation steps for different storage options:&lt;/p&gt;

&lt;h3&gt;
  
  
  File Storage:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install errsole errsole-sqlite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MongoDB:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install errsole errsole-mongodb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  MySQL:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install errsole errsole-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PostgreSQL:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install errsole errsole-postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating a Custom Logger File
&lt;/h2&gt;

&lt;p&gt;In a real-life Node.js project, you will have multiple files. To use the Errsole Logger in every file of your project, create a &lt;code&gt;logger.js&lt;/code&gt; file and initialize Errsole in it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const errsole = require('errsole');
const ErrsoleSQLite = require('errsole-sqlite');

errsole.initialize({
  storage: new ErrsoleSQLite('/tmp/logs.sqlite')
});

module.exports = errsole;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can import the &lt;code&gt;logger.js&lt;/code&gt; file in every file in your project and use it to log:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const logger = require('./logger');

// Example usage
logger.info('This is an informational message.');
logger.error('This is an error message.');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding Log Levels in Errsole
&lt;/h2&gt;

&lt;p&gt;Errsole Logger functions take the same arguments as &lt;code&gt;console.log&lt;/code&gt;. You can provide one or more strings, objects, or variables separated by a comma. Additionally, you can attach metadata to your log messages using the meta function. This metadata can be any contextual information, such as HTTP requests or database query results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.meta({ reqBody: req.body, queryResults: results }).error(err);
logger.meta({ email: req.body.email }).log('User logged in');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Errsole Logger provides functions for five log levels: alert, error, warn, info, and debug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;log / info:&lt;/strong&gt; Use to log messages or information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.log('Logging a message');
logger.log('Multiple', 'arguments', 'are supported');
logger.log('Logging with a variable:', var1);
logger.log(new Error('An error occurred'));
logger.log('Logging with an error object:', errorObject);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;alert:&lt;/strong&gt; Logs a message and sends a notification to configured channels, such as Email or Slack.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.alert('Alert! Something critical happened');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;error:&lt;/strong&gt; Specifically designed to log errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.error(new Error('An error occurred'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;warn:&lt;/strong&gt; Logs warning messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.warn('This is a warning message');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;debug:&lt;/strong&gt; Logs debug information, typically used for troubleshooting during development.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.debug('Debugging information');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to use &lt;code&gt;logger.alert&lt;/code&gt; in your code
&lt;/h2&gt;

&lt;p&gt;Whenever your Node.js application crashes, Errsole sends a real-time notification to your development team. This notification includes the error message, the app name, the environment name, and the server name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvakrnhbcl9k5mwvxuc04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvakrnhbcl9k5mwvxuc04.png" alt="Image description" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To add critical errors to this notification list, use &lt;code&gt;logger.alert&lt;/code&gt; in your code. However, avoid overusing it to prevent flooding your developers with notifications. Use it for critical errors like payment failures or database query failures. Put the error object in the alert function and add all contextual information in the meta function. This allows developers to easily debug critical errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.meta({ reqBody: req.body, queryResults: results }).alert(err);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Incorporating a complete logging solution into your Node.js application ensures robust log management and efficient debugging. Errsole provides log storage, a built-in dashboard, and real-time notifications, making it a complete logging tool.&lt;/p&gt;

&lt;p&gt;To get started with Errsole, visit &lt;a href="https://github.com/errsole/errsole.js" rel="noopener noreferrer"&gt;https://github.com/errsole/errsole.js&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>opensource</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A new Node.js logger that does more than Winston and Pino</title>
      <dc:creator>Venki</dc:creator>
      <pubDate>Fri, 07 Jun 2024 11:08:26 +0000</pubDate>
      <link>https://forem.com/errsole/a-new-nodejs-logger-that-does-more-than-winston-and-pino-4h08</link>
      <guid>https://forem.com/errsole/a-new-nodejs-logger-that-does-more-than-winston-and-pino-4h08</guid>
      <description>&lt;p&gt;Popular Node.js loggers like Winston, Pino, and Bunyan are good for collecting logs, but that's pretty much all they do. They don't come with any built-in tools to visualize or search through the logs. Because of this, developers often need to set up Elastic Stack on dedicated servers or pay for a service to handle log storage and visualization.&lt;/p&gt;

&lt;p&gt;From what I have gathered in conversations with many developers, a lot of them are just streaming logs to files. When an error occurs, they manually download and search through these logs to find the issue.&lt;/p&gt;

&lt;p&gt;We have converted key features of &lt;a href="https://www.errsole.com/" rel="noopener noreferrer"&gt;Errsole Cloud&lt;/a&gt; to open source and released them under the MIT license.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Motive
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Complete Logger:&lt;/strong&gt; A single module should collect and store logs, as well as provide a web dashboard for viewing and searching the logs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy Setup:&lt;/strong&gt; The module should be easy to set up, without requiring dedicated servers or the installation of third-party software.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Easy Setup:&lt;/strong&gt; Just install and configure the module. That's it! Errsole handles the collection, storage, and visualization of logs within the module itself. No additional software installations or dedicated servers are required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete Logger:&lt;/strong&gt; One of the main issues with loggers like Winston and Pino is that they do not capture default console logs. When errors occur in dependency modules, these modules use &lt;code&gt;console.error&lt;/code&gt; or &lt;code&gt;console.warn&lt;/code&gt; to log the issues. Winston and Pino miss these logs entirely. To address this, we have decided to capture default console logs in addition to providing a &lt;a href="https://github.com/errsole/errsole.js?tab=readme-ov-file#custom-logging-functions" rel="noopener noreferrer"&gt;custom logger&lt;/a&gt; with multiple log levels in Errsole.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time Notifications:&lt;/strong&gt; One of the essential features that developers often miss is receiving alerts for app crashes and critical errors. Typically, developers need to use a paid service for this, but it is a crucial requirement. To address this need, we have decided to add this feature to our open-source project. When an app crashes or encounters a critical error, Errsole Open Source will send a notification to developers via Email or Slack. This notification will include the error message, the app name, the environment, and the server name.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;a href="https://www.youtube.com/watch?si=rwRAPuoKz9y-_faa&amp;amp;v=ppTzjx6DqO8&amp;amp;feature=youtu.be" rel="noopener noreferrer"&gt;
      youtube.com
    &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Errsole aims to provide a complete &lt;a href="https://github.com/errsole/errsole.js" rel="noopener noreferrer"&gt;logging tool&lt;/a&gt; for Node.js applications, addressing the limitations of existing loggers and making it easier for developers to monitor and maintain their applications. Try Errsole and see how it can enhance your logging and monitoring workflow. We would love to hear your feedback!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/errsole/errsole.js" rel="noopener noreferrer"&gt;https://github.com/errsole/errsole.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>nestjs</category>
    </item>
  </channel>
</rss>
