diff --git a/src/config.ts b/src/config.ts index c33c646bb4..8a6a683702 100644 --- a/src/config.ts +++ b/src/config.ts @@ -56,6 +56,7 @@ interface ISource { siteKey: string; secretKey: string; }; + accesslog: string; } /** diff --git a/src/server.ts b/src/server.ts index aa1627e028..485746caf3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -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) => {