Write also /var/lib/icinga2/api/zones-stage-startup-last-failed.log

in addition to /var/lib/icinga2/api/zones-stage-startup.log
to prevent the next success to overwrite the last failure.
This commit is contained in:
Alexander A. Klimov 2022-04-07 11:30:52 +02:00
parent ce6d1b8961
commit 08a23f4035
1 changed files with 6 additions and 1 deletions

View File

@ -645,10 +645,15 @@ void ApiListener::TryActivateZonesStage(const std::vector<String>& relativePaths
return;
}
String failedLogFile = apiDir + "/zones-stage-startup-last-failed.log";
std::ofstream fpFailedLog(failedLogFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
fpFailedLog << pr.Output;
fpFailedLog.close();
// Error case.
Log(LogCritical, "ApiListener")
<< "Config validation failed for staged cluster config sync in '" << apiZonesStageDir
<< "'. Aborting. Logs: '" << logFile << "'";
<< "'. Aborting. Logs: '" << failedLogFile << "'";
ApiListener::Ptr listener = ApiListener::GetInstance();