Skip to content

Commit 0f54cc6

Browse files
committed
fix: use silly level on production Console transport
Winston 3 treats a transport's `level` independently from the logger's level -- the logger's level is only the default for transports that don't specify their own. Without setting a level on the new production Console transport, it inherited the logger's level (APP.LOG_LEVEL, default info), so verbose/debug lines never reached journalctl even though the existing debug-%DATE%.log file captured them. Set `level: 'silly'` on the Console transport so journalctl receives every log line the app emits, regardless of APP.LOG_LEVEL. File transports are untouched.
1 parent 0adf362 commit 0f54cc6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/config/logger.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,18 @@ const createVersionLogger = (version) => {
118118
);
119119
} else {
120120
// In production, also stream every log line the logger emits to the
121-
// process's stdout/stderr so operators can consume them via journalctl,
122-
// pm2, or docker. File transports above continue to hold the same data
123-
// on disk. Errors go to stderr, everything else to stdout.
121+
// process's stdout/stderr so operators can consume the full log stream
122+
// via journalctl, pm2, or docker. File transports above continue to
123+
// hold the same data on disk. Errors go to stderr, everything else to
124+
// stdout.
125+
//
126+
// NOTE: in winston 3 a transport's `level` is independent of the
127+
// logger's level, so we explicitly use 'silly' (the most permissive
128+
// level) to guarantee that anything the app logs reaches journalctl,
129+
// regardless of APP.LOG_LEVEL.
124130
versionLogger.add(
125131
new transports.Console({
132+
level: 'silly',
126133
stderrLevels: ['error'],
127134
format: format.combine(format.json()),
128135
}),

0 commit comments

Comments
 (0)