diff --git a/config/logger.ts b/config/logger.ts index ece6c76..4215811 100644 --- a/config/logger.ts +++ b/config/logger.ts @@ -1,10 +1,17 @@ import { winston } from "@strapi/logger"; import { formatLogLine } from "../src/logging/format"; +// Strapi 4.25 creates its logger from @strapi/logger's default configuration with this object assigned over it +// (Strapi.js: createLogger(this.config.get("logger"))). Its default level is "silly", which writes every line, also the debug and +// silly lines with order data such as names and addresses. Production (NODE_ENV=production in mp's compose.yml) writes info and +// above, any other environment debug and above. +const level = process.env.NODE_ENV === "production" ? "info" : "debug"; + export default { + level, transports: [ new winston.transports.Console({ - format: winston.format.combine(winston.format.printf(formatLogLine)) + format: winston.format.combine(winston.format.printf((info) => formatLogLine(info, { stack: level === "debug" }))) }) ] };