From b964c0d4881cb998cb3e58f25b93cfa4326bdc28 Mon Sep 17 00:00:00 2001 From: Martin Sander Date: Wed, 26 Jan 2022 20:25:34 +0100 Subject: [PATCH] fix: re-opening log files using SIGUSR2 (#2966) by @marvinthepa --- src/lib/logger/logger.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/logger/logger.ts b/src/lib/logger/logger.ts index 5a25f106e..21ef20438 100644 --- a/src/lib/logger/logger.ts +++ b/src/lib/logger/logger.ts @@ -122,7 +122,9 @@ export function setup(options: LoggerConfig | LoggerConfigItem = [DEFAULT_LOGGER const pinoConfig = { level: loggerConfig.level }; if (loggerConfig.type === 'file') { debug('logging file enabled'); - logger = createLogger(pinoConfig, pino.destination(loggerConfig.path), loggerConfig.format); + const destination = pino.destination(loggerConfig.path); + process.on('SIGUSR2', () => destination.reopen()); + logger = createLogger(pinoConfig, destination, loggerConfig.format); } else if (loggerConfig.type === 'rotating-file') { process.emitWarning('rotating-file type is not longer supported, consider use [logrotate] instead'); debug('logging stdout enabled');