アクセスログを書き込むファイルを指定できるように

This commit is contained in:
syuilo 2017-01-20 10:19:09 +09:00
parent 2a21095299
commit bd04f16edd
2 changed files with 5 additions and 2 deletions

View file

@ -56,6 +56,7 @@ interface ISource {
siteKey: string;
secretKey: string;
};
accesslog: string;
}
/**

View file

@ -19,8 +19,10 @@ const app = express();
app.disable('x-powered-by');
// Log
app.use(morgan(
process.env.NODE_ENV == 'production' ? 'combined' : 'dev'));
app.use(morgan(process.env.NODE_ENV == 'production' ? 'combined' : 'dev', {
// create a write stream (in append mode)
stream: config.accesslog ? fs.createWriteStream(config.accesslog) : null
}));
// Drop request that without 'Host' header
app.use((req, res, next) => {