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 :: express.js hello world 
Javascript :: check browser 
Javascript :: regex 
Javascript :: Appending the option element using jquery each function 
Javascript :: window scroll up 
Javascript :: DC League of Super-Pets 
Javascript :: curl send json as variable 
Javascript :: javascript convert utc to local time 
Javascript :: class component react 
Javascript :: html get form elements 
Javascript :: remove substring from string liquid shopify 
Javascript :: get height webview from url video react native 
Javascript :: convert html to pdf using javascript 
Javascript :: javascript array clear 
Javascript :: Class constructor cannot be invoked without new 
Javascript :: js array random 
Javascript :: make a bot send a welcome message discordjs 
Javascript :: search a word and separate in javascript 
Javascript :: class javascript 
Javascript :: apache react deploy "conf" 
Javascript :: generate empty array js 
Javascript :: split string with last character and return array in javascript 
Javascript :: nuxt store watch 
Javascript :: make an arry from a string 
Javascript :: nodejs redirect to url 
Javascript :: shorthand if statement js 
Javascript :: firebase sign up with email and password 
Javascript :: Check the render method of `App` 
Javascript :: check if array exists in another array javascript 
Javascript :: how to use labels in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =