Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node.js log to file

const { Console } = require('console');

const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
// Custom simple logger
const logger = new Console({ stdout: output, stderr: errorOutput });
// use it like console
const count = 5;
logger.log('count: %d', count);
// In stdout.log: count 5
Comment

save console log to file nodejs

node app.js > app.log 2>&1
Comment

nodejs write to log file

var access = fs.createWriteStream(dir + '/node.access.log', { flags: 'a' })
      , error = fs.createWriteStream(dir + '/node.error.log', { flags: 'a' });

// redirect stdout / stderr
proc.stdout.pipe(access);
proc.stderr.pipe(error);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript hide elements by class 
Javascript :: magento 2 translate js 
Javascript :: react state value not updating in function 
Javascript :: get parameter from url using jquery 
Javascript :: javascript array to string with commas 
Javascript :: json db 
Javascript :: nodejs generate ethereum address 
Javascript :: run function on page resize javascript 
Javascript :: anagram checker javascript 
Javascript :: javascript Program for Sum of the digits of a given number 
Javascript :: Sort an array to have specific items 
Javascript :: Uncaught TypeError: $(...).jstree is not a function 
Javascript :: javascript write to firebase 
Javascript :: add decimals javascript 
Javascript :: jquery disable all forms 
Javascript :: jest Your test suite must contain at least one test. 
Javascript :: nuxt add plugin 
Javascript :: body-parser vs express.json 
Javascript :: for loop in shopify liquid template 
Javascript :: run node js 
Javascript :: remove specific item from array 
Javascript :: show password fa-eye javascript 
Javascript :: javascript loop through array backwards 
Javascript :: javascript remove object from array 
Javascript :: jquery check is select 
Javascript :: http module in nodejs 
Javascript :: electron js nodeintegration 
Javascript :: patterns in javascript 
Javascript :: js .substring 
Javascript :: how to convert an array into single quote strings 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =