Created
January 19, 2017 07:06
-
-
Save iworkforthem/5c583c1f0752bf80de70f16d97cc6661 to your computer and use it in GitHub Desktop.
request logging & secure HTTP headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var helmet = require('helmet'); | |
app.use(helmet()); | |
var morgan = require('morgan'); | |
var fs = require('fs'); | |
var FileStreamRotator = require('file-stream-rotator') | |
var logDirectory = __dirname + '/logs' | |
fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory); | |
var accessLogStream = FileStreamRotator.getStream({ | |
date_format: 'YYYYMMDD', | |
filename: logDirectory + '/access-%DATE%.log', | |
frequency: 'daily', | |
verbose: false | |
}) | |
app.use(morgan('combined', { | |
stream: accessLogStream | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment