diff --git a/api/now.js b/api/now.js index a91f4f2e84..085cc0c1ef 100644 --- a/api/now.js +++ b/api/now.js @@ -1,5 +1,10 @@ +const config = require('../lib/config'); const app = require('../lib/app'); +config.set({ + noLogFiles: true, +}); + module.exports = (req, res) => { app.callback()(req, res); }; diff --git a/lib/config.js b/lib/config.js index 9573cc46f6..cd220bff16 100644 --- a/lib/config.js +++ b/lib/config.js @@ -25,7 +25,8 @@ const calculateValue = () => { } value = { - isPackage: envs.isPackage, + isPackage: false, + noLogfiles: envs.NO_LOGFILES, connect: { port: envs.PORT || 1200, // 监听端口 socket: envs.SOCKET || null, // 监听 Unix Socket, null 为禁用 diff --git a/lib/utils/logger.js b/lib/utils/logger.js index 642f494a7a..7dfd4a2c7b 100644 --- a/lib/utils/logger.js +++ b/lib/utils/logger.js @@ -2,20 +2,20 @@ const { resolve } = require('path'); const winston = require('winston'); const config = require('@/config').value; -const logger = winston.createLogger({ - level: config.loggerLevel, - format: winston.format.json(), - transports: [ - // - // - Write to all logs with level `info` and below to `combined.log` - // - Write all logs error (and below) to `error.log`. - // +let transports = []; +if (!config.noLogfiles) { + transports = [ new winston.transports.File({ filename: resolve('logs/error.log'), level: 'error', }), new winston.transports.File({ filename: resolve('logs/combined.log') }), - ], + ]; +} +const logger = winston.createLogger({ + level: config.loggerLevel, + format: winston.format.json(), + transports: transports, }); //