From 65cd5b2f1ee74f5772165a410d9dbf3d836f3851 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 15 Sep 2023 10:01:56 -0400 Subject: [PATCH] express: log to a file, rather than what docker might lose Signed-off-by: Vincent Batts --- express/server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/express/server.js b/express/server.js index b521cc5..28bae79 100644 --- a/express/server.js +++ b/express/server.js @@ -1,5 +1,6 @@ const express = require('express'); const fs = require('fs'); +const path = require('path'); const morgan = require('morgan'); const bodyParser = require('body-parser'); const sqlite3 = require('sqlite3').verbose(); @@ -25,8 +26,10 @@ const db = new sqlite3.Database('db/results.db', (err) => { } }); +var accessLogStream = fs.createWriteStream(path.join(__dirname, 'log', 'access.log'), { flags: 'a' }) + app.use(bodyParser.json()); -app.use(morgan('combined')); +app.use(morgan('combined', { stream: accessLogStream })); var animals; // check and load animals into redis