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 create folder 
Javascript :: javascript update text in div 
Javascript :: how to use javascript in flutter 
Javascript :: execute command javascript 
Javascript :: edit external json file in javascript 
Javascript :: tooltip in chakra ui 
Javascript :: datatables cdn 
Javascript :: js sum 
Javascript :: xlsx js 
Javascript :: regex pattern for password 
Javascript :: react native flexbox 2 columns 1 fixed width 
Javascript :: label in lwc 
Javascript :: coffeescript to javascript 
Javascript :: async arrow function js 
Javascript :: js .touppercase 
Javascript :: jQuery load() Method 
Javascript :: find multiple javascript 
Javascript :: TYPING TEXT USING JS 
Javascript :: nodejs http get request to external server 
Javascript :: exploding string with comma using jquery 
Javascript :: jest invalid or unexpected token 
Javascript :: make property read-only javascript 
Javascript :: javascript for loop array of objects 
Javascript :: what does document.getelementbyid return 
Javascript :: json deep dot 
Javascript :: format json command line 
Javascript :: nuxt vuetify google fonts 
Javascript :: react component will mount new method 
Javascript :: js remove last char of string 
Javascript :: how to add items to object in javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =