Update 2013 – This was written around Node v0.2 and v0.4; There are much better utilites now around logging. I highly recommend Winston
Update Late 2013 – We still use winston, but now with a logger library to wrap the functionality around logging of custom objects and formatting. Here is a sample of our logger.js https://gist.github.com/rtgibbons/7354879
Should be as simple as this.
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);
Related Posts:
- How can I send a message to the systemd journal from the command line?
- IIS: Where can I find the IIS logs?
- How do I convert dmesg timestamp to custom date format?
- Log.INFO vs. Log.DEBUG
- Are there any log file about Windows Services Status?
- How to view snort log files
- Where is the Docker daemon log?
- Is it possible to run one logrotate check manually?
- Log of Heartbeat Calls
- Custom and browser agent logging in wordpress [closed]
- Logging Count of Those Who Read Whole Post (ie reach the bottom)
- Does WordPress provide different levels of logging?
- Can I hook error_log(…)?
- Debug log file with rolling datestamp in filename?
- how to make a code which save admin each time login and logout activity inside a table
- Make a Docker application write to stdout
- ISO Plugin: Audit Trail with Diff of Content Changes
- How to make a discord bot create an invite for every server it joins?
- map function for objects (instead of arrays)
- I can´t install nodemon globally, “nodemon” not recognized
- What is console.log?
- How can I update NodeJS and NPM to the next versions?
- How can I update npm itself?
- How do I update Node.js?
- How to install a previous exact version of a NPM package?
- How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’
- How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’
- How to solve npm error “npm ERR! code ELIFECYCLE”
- Start script missing error when running npm start
- How to solve npm error “npm ERR! code ELIFECYCLE”
- npm check and update package if needed
- What is the file node.exe for?
- Node.js version on the command line? (not the REPL)
- Can not find module “@angular-devkit/build-angular”
- Node.exe Stuck at 100% CPU
- After command npm start “Missing script:start” error
- sudo: npm: command not found
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general? [closed]
- Discord API error when trying to send one command at discord using JavaScript client
- How to you store data for each discord user in the discord server?
- Upgrading Node.js to latest version
- How to resolve Nodejs: Error: ENOENT: no such file or directory
- bash: npm: command not found?
- Babel 6 regeneratorRuntime is not defined
- TypeError: Converting circular structure to JSON in nodejs
- Babel 7 – ReferenceError: regeneratorRuntime is not defined
- Node.js getaddrinfo ENOTFOUND
- How do I debug error ECONNRESET in Node.js?
- How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
- Node.js getaddrinfo ENOTFOUND
- How do I debug error ECONNRESET in Node.js?
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- How to fix “ReferenceError: primordials is not defined” in Node.js
- Does anyone knows what “rimraf” means?
- How can I completely uninstall nodejs, npm and node in Ubuntu [closed]
- Please run `npm cache clean`
- Client on Node.js: Uncaught ReferenceError: require is not defined
- What is this JavaScript “require”?
- Error: Can’t set headers after they are sent to the client
- How can a Discord bot create a hyperlink in a Discord message in an embed or in general?
- Getting a UnhandledPromiseRejectionWarning when testing using mocha/chai
- node.js string.replace doesn’t work?
- What is the difference between npm install and npm run build?
- require is not defined? Node.js
- Client on Node.js: Uncaught ReferenceError: require is not defined
- What is this JavaScript “require”?
- Error: Can’t set headers after they are sent to the client
- TypeError: Router.use() requires middleware function but got a Object
- Express error – TypeError: Router.use() requires middleware function but got a Object
- What is “export default” in JavaScript?
- What is Express.js?
- Cannot GET / Nodejs Error
- How do I resolve “Cannot find module” error using Node.js?
- What is NODE_ENV and how to use it in Express?
- npm ERR cb() never called
- python exception message capturing
- Node.js heap out of memory
- Missing write access in mac to /usr/local/lib/node_modules
- Reactjs – Form input validation
- What is the difference between __dirname and ./ in node.js?
- NPM clean modules
- ‘node’ is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova
- How can the default node version be set using NVM?
- await is only valid in async function
- What does body-parser do with express?
- “Cannot GET /” with Connect on Node.js
- How to set NODE_ENV to production/development in OS X
- await is only valid in async function
- node.js, Error: Cannot find module ‘express’
- nodemon app crashed – waiting for file changes before starting
- Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
- Heroku: “No default language could be detected for this app” error thrown for node app
- Heroku: “No default language could be detected for this app” error thrown for node app
- env: node: No such file or directory in mac
- mongoError: Topology was destroyed
- NPM Start not starting local server
- Error: unable to verify the first certificate in nodejs
- TypeError: Router.use() requires middleware function but got a Object
- node.js, Error: Cannot find module ‘express’
- nodemon – app crashed – waiting for file changes before starting