Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Create Nodejs logger that does not replace file when app/server restarts

const { Console } = require('console'); // get the Console class
const fs = require('fs'); // get fs module for creating write streams

// make a new logger
const eventsLogger = new Console({
  stdout: fs.createWriteStream('logs/eventsLog.txt', {
    flags: 'a+',
  }), // a write stream (normal log outputs)
  stderr: fs.createWriteStream('logs/eventsErrorLog.txt', {
    flags: 'a+',
  }), // a write stream (error outputs)
});

eventsLogger.log("Normal logged message");
eventsLogger.error('Error in connecting to database');
Comment

PREVIOUS NEXT
Code Example
Javascript :: This Refers To The Window Object Here 
Javascript :: how to add random color in chart in react j 
Javascript :: Staircase 
Javascript :: replace text content with element node 
Javascript :: Self Invoking Function Tip 
Javascript :: javascript ls 
Javascript :: jquery target all the li element using jquery 
Javascript :: show hide element with javascript stack overflow 
Javascript :: react_devtools_backend.js:4026 Warning: Cannot update a component (`BrowserRouter`) while rendering a different component (`Login`). 
Javascript :: air config file 
Javascript :: Declare Function To Be Used In Class 
Javascript :: Joi conditional validation refer parent object 
Javascript :: javascript hide div 
Javascript :: prisma is and isNot 
Javascript :: create object in jquery dynamically 
Javascript :: mul function call to 3 functions 
Javascript :: var maxNum = function(arr) {}; 
Javascript :: verify if user input is equal to javascript 
Javascript :: Backbone Router Notes 
Javascript :: adding javascript object within array in the last position 
Javascript :: java scrypt 
Javascript :: password generator and password strength using javascript 
Javascript :: popper js 
Javascript :: change string to int javascript 
Javascript :: jwt_access_secret generator 
Javascript :: remove backslash from json 
Javascript :: color switcher 
Javascript :: heroku 
Javascript :: java script layout engine error 
Javascript :: javascript map size 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =