Don't truncate logs after rotation.

This commit is contained in:
levlam 2022-11-01 14:13:14 +03:00
parent 8c694cd3d3
commit e11804b5b0
2 changed files with 2 additions and 2 deletions

View File

@ -38,7 +38,7 @@ Status AsyncFileLog::init(string path, int64 rotate_threshold, bool redirect_std
auto after_rotation = [&] {
ScopedDisableLog disable_log; // to ensure that nothing will be printed to the closed log
fd.close();
auto r_fd = FileFd::open(path, FileFd::Create | FileFd::Truncate | FileFd::Write);
auto r_fd = FileFd::open(path, FileFd::Create | FileFd::Write | FileFd::Append);
if (r_fd.is_error()) {
process_fatal_error(PSLICE() << r_fd.error() << " in " << __FILE__ << " at " << __LINE__ << '\n');
}

View File

@ -115,7 +115,7 @@ void FileLog::do_after_rotation() {
ScopedDisableLog disable_log; // to ensure that nothing will be printed to the closed log
CHECK(!path_.empty());
fd_.close();
auto r_fd = FileFd::open(path_, FileFd::Create | FileFd::Truncate | FileFd::Write);
auto r_fd = FileFd::open(path_, FileFd::Create | FileFd::Write | FileFd::Append);
if (r_fd.is_error()) {
process_fatal_error(PSLICE() << r_fd.error() << " in " << __FILE__ << " at " << __LINE__ << '\n');
}