diff --git a/packages/core/basic/src/utils/util.log.ts b/packages/core/basic/src/utils/util.log.ts index 90cbb7a2..171da309 100644 --- a/packages/core/basic/src/utils/util.log.ts +++ b/packages/core/basic/src/utils/util.log.ts @@ -18,16 +18,31 @@ const OutputAppender = { }, }; +let logFilePath = "./logs/app.log"; export function resetLogConfigure() { // @ts-ignore log4js.configure({ - appenders: { std: { type: "stdout" }, output: { type: OutputAppender } }, - categories: { default: { appenders: ["std"], level: "info" }, pipeline: { appenders: ["std", "output"], level: "info" } }, + appenders: { + std: { type: "stdout" }, + output: { type: OutputAppender }, + file: { + type: "dateFile", + filename: logFilePath, + keepFileExt: true, + compress: true, + numBackups: 3, + }, + }, + categories: { default: { appenders: ["std", "file"], level: "info" }, pipeline: { appenders: ["std", "file", "output"], level: "info" } }, }); } resetLogConfigure(); export const logger = log4js.getLogger("default"); +export function resetLogFilePath(filePath: string) { + logFilePath = filePath; + resetLogConfigure(); +} export function buildLogger(write: (text: string) => void) { const logger = log4js.getLogger("pipeline"); const _secrets: string[] = []; diff --git a/packages/ui/certd-server/src/config/config.default.ts b/packages/ui/certd-server/src/config/config.default.ts index bd760f3b..dc616cf6 100644 --- a/packages/ui/certd-server/src/config/config.default.ts +++ b/packages/ui/certd-server/src/config/config.default.ts @@ -19,6 +19,12 @@ import path from 'path'; const env = process.env.NODE_ENV || 'development'; const development = { + midwayLogger: { + default: { + dir: './logs', + }, + // ... + }, keys: 'certd', koa: { port: 7001,