Skip to content

Commit 56cca04

Browse files
committed
fix: mirror error-level logs to stderr in production
With NODE_ENV=production, the logger had no Console transport, so logger.error(...) calls only reached the on-disk log files and were invisible to journalctl/pm2/docker. The previous console.trace fallback in the staging commit handler was the only thing operators saw in systemd for that endpoint. Add a production-only Console transport at error level with stderrLevels so errors are written to process.stderr and picked up by the process supervisor, without pushing verbose/info/debug traffic into journalctl. File transports are unchanged, so the full log stream still lives on disk.
1 parent 037424f commit 56cca04

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/config/logger.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ const createVersionLogger = (version) => {
116116
),
117117
}),
118118
);
119+
} else {
120+
// In production, mirror error-level logs to stderr so operators can see
121+
// them via journalctl/pm2/docker alongside the on-disk log files.
122+
versionLogger.add(
123+
new transports.Console({
124+
level: 'error',
125+
stderrLevels: ['error'],
126+
format: format.combine(format.json()),
127+
}),
128+
);
119129
}
120130

121131
return versionLogger;

0 commit comments

Comments
 (0)