Skip to content

Commit

Permalink
Merge ec9651b into 572dd93
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjb committed Oct 4, 2018
2 parents 572dd93 + ec9651b commit 1fe7b12
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,18 @@ app.get('/', function (req, res) {
Simple app that will log all requests in the Apache combined format to one log
file per day in the `log/` directory using the
[rotating-file-stream module](https://www.npmjs.com/package/rotating-file-stream).
The `rotating-file-stream` module will automatically create the log directory in
this example if it doesn't already exist.

```js
var express = require('express')
var fs = require('fs')
var morgan = require('morgan')
var path = require('path')
var rfs = require('rotating-file-stream')

var app = express()
var logDirectory = path.join(__dirname, 'log')

// ensure log directory exists
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory)

// create a rotating write stream
var accessLogStream = rfs('access.log', {
interval: '1d', // rotate daily
Expand Down

0 comments on commit 1fe7b12

Please sign in to comment.