diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index 7884b6f29..617ebeb16 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -347,9 +347,12 @@ void applyJSONLogger() try { std::vector> loggers; loggers.push_back(makeJSONLogger(std::filesystem::path(loggerSettings.jsonLogPath.get()), false)); - // Note: this had better not throw, otherwise `logger` is - // left unset. - logger = makeTeeLogger(std::move(logger), std::move(loggers)); + try { + logger = makeTeeLogger(std::move(logger), std::move(loggers)); + } catch (...) { + // `logger` is now gone so give up. + abort(); + } } catch (...) { ignoreExceptionExceptInterrupt(); }