<?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: Venki</title>
    <description>The latest articles on Forem by Venki (@venki91).</description>
    <link>https://forem.com/venki91</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%2Fuser%2Fprofile_image%2F834652%2Ff96c44c1-4d21-4e21-b44a-44ba91de9f3b.png</url>
      <title>Forem: Venki</title>
      <link>https://forem.com/venki91</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/venki91"/>
    <language>en</language>
    <item>
      <title>How to set up a Node.js Log Viewer</title>
      <dc:creator>Venki</dc:creator>
      <pubDate>Tue, 08 Apr 2025 13:25:44 +0000</pubDate>
      <link>https://forem.com/venki91/-1707</link>
      <guid>https://forem.com/venki91/-1707</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp" class="crayons-story__hidden-navigation-link"&gt;How to set up a Node.js Log Viewer: a step-by-step guide&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;
          &lt;a class="crayons-logo crayons-logo--l" href="/errsole"&gt;
            &lt;img alt="errsole logo" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F6325%2Fcabc08fa-af2a-47b5-9988-834bebc77196.png" class="crayons-logo__image"&gt;
          &lt;/a&gt;

          &lt;a href="/venki91" class="crayons-avatar  crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F834652%2Ff96c44c1-4d21-4e21-b44a-44ba91de9f3b.png" alt="venki91 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/venki91" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Venki
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Venki
                
              
              &lt;div id="story-author-preview-content-2391569" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/venki91" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F834652%2Ff96c44c1-4d21-4e21-b44a-44ba91de9f3b.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Venki&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;span&gt;
              &lt;span class="crayons-story__tertiary fw-normal"&gt; for &lt;/span&gt;&lt;a href="/errsole" class="crayons-story__secondary fw-medium"&gt;errsole&lt;/a&gt;
            &lt;/span&gt;
          &lt;/div&gt;
          &lt;a href="https://dev.to/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 8 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp" id="article-link-2391569"&gt;
          How to set up a Node.js Log Viewer: a step-by-step guide
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/errsole/how-to-set-up-a-nodejs-log-viewer-a-step-by-step-guide-33cp#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>javascript</category>
      <category>logging</category>
      <category>howto</category>
      <category>tutorial</category>
    </item>
    <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>How to set up Errsole Node.js Logger across all environments</title>
      <dc:creator>Venki</dc:creator>
      <pubDate>Mon, 23 Dec 2024 12:57:22 +0000</pubDate>
      <link>https://forem.com/venki91/how-to-set-up-errsole-nodejs-logger-across-all-environments-1n6j</link>
      <guid>https://forem.com/venki91/how-to-set-up-errsole-nodejs-logger-across-all-environments-1n6j</guid>
      <description>&lt;h2&gt;
  
  
  What is Errsole?
&lt;/h2&gt;

&lt;p&gt;Errsole is an open-source logging library for Node.js applications. What sets Errsole apart is its built-in log viewer, which allows you to view, filter, and search your application logs. If you are scrolling through raw log files or SSHing into servers to access your logs, Errsole is a must-include library in your codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up Errsole across all environments
&lt;/h2&gt;

&lt;p&gt;In this setup, logs in the development environment are stored locally in an SQLite file. In the production environment, logs are stored in a centralized MongoDB database.&lt;/p&gt;

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

&lt;p&gt;Run the following commands to install Errsole and its storage adapters:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Create the logger file
&lt;/h3&gt;

&lt;p&gt;Create a file named &lt;code&gt;logger.js&lt;/code&gt; to handle Errsole’s initialization for all environments.&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 ErrsoleMongoDB = require('errsole-mongodb');
const ErrsoleSQLite = require('errsole-sqlite');
const os = require('os');
const path = require('path');

if (process.env.NODE_ENV === 'production') {
  // Production Environment: Centralized logging with MongoDB
  errsole.initialize({
    storage: new ErrsoleMongoDB('&amp;lt;Connection URL&amp;gt;', '&amp;lt;Collection Name&amp;gt;', { collectionPrefix: '&amp;lt;App Name&amp;gt;' }),
    appName: '&amp;lt;App Name&amp;gt;',
    environmentName: process.env.NODE_ENV,
  });
} else {
  // Development/Other Environments: Local logging with SQLite
  const logsFile = path.join(os.tmpdir(), '&amp;lt;App Name&amp;gt;.log.sqlite');
  errsole.initialize({
    storage: new ErrsoleSQLite(logsFile),
    appName: '&amp;lt;App Name&amp;gt;',
    environmentName: process.env.NODE_ENV,
  });
}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Use Errsole in your application
&lt;/h3&gt;

&lt;p&gt;Include the logger in your application to start capturing logs.&lt;br&gt;
&lt;/p&gt;

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

const app = express();

// Middleware to access Errsole log viewer
app.use('/errsole', logger.expressProxyMiddleware());

app.get('/', (req, res) =&amp;gt; {
  logger.info('Home route accessed'); // Log an info message
  res.send('Hello, World!');
});

const port = 3000;
app.listen(port, () =&amp;gt; {
  logger.info(`Server running on port ${port}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Access the Log Viewer
&lt;/h3&gt;

&lt;p&gt;With the above configuration, you can access the Errsole Web Dashboard by visiting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:3000/errsole
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Errsole with Other Storages
&lt;/h2&gt;

&lt;p&gt;This guide uses MongoDB for centralized logging in production. However, Errsole supports other databases like MySQL and PostgreSQL. For detailed instructions, refer to the following documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/errsole/errsole.js/blob/master/docs/mongodb-storage.md" rel="noopener noreferrer"&gt;Errsole with MongoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/errsole/errsole.js/blob/master/docs/mysql-storage.md" rel="noopener noreferrer"&gt;Errsole with MySQL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/errsole/errsole.js/blob/master/docs/postgresql-storage.md" rel="noopener noreferrer"&gt;Errsole with PostgreSQL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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>
