From c560de8ec0a73721ad6cbb33440c9ea5985193d5 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Fri, 9 Oct 2026 01:42:17 +0200 Subject: [PATCH] fix(logging): log at info in production instead of silly Strapi 4.25 builds its logger from @strapi/logger's default configuration with config/logger.ts assigned over it. That default level is "silly", and config/logger.ts set none, so production wrote every level: the logger of the v0.1.1 image, built as Strapi builds it with NODE_ENV=production, reports level silly. Debug and silly lines carry order data, such as the PayPal order request with the buyer's name and address. The level is now info for NODE_ENV=production, which mp's compose.yml sets for the cms, and debug in every other environment. Strapi's request log lines are written at http, below info, so production no longer writes them. The stack of an error field is written at debug only. Refs https://git.librete.ch/libretech/mp/issues/71 Refs https://git.librete.ch/libretech/mp/issues/67 --- config/logger.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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" }))) }) ] };