From bd04f16eddf0c7f464da67951523c125950b1732 Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Fri, 20 Jan 2017 10:19:09 +0900
Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E3=83=AD?=
 =?UTF-8?q?=E3=82=B0=E3=82=92=E6=9B=B8=E3=81=8D=E8=BE=BC=E3=82=80=E3=83=95?=
 =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=A7?=
 =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/config.ts | 1 +
 src/server.ts | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/config.ts b/src/config.ts
index c33c646bb..8a6a68370 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 aa1627e02..485746caf 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) => {