Skip to content

Commit bf707aa

Browse files
committed
appender: prune old logs when building the appender for the first time
1 parent 47b5089 commit bf707aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tracing-appender/src/rolling.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ impl Inner {
596596
max_file_size,
597597
};
598598
let filename = inner.join_date(&now);
599+
if let Some(max_files) = inner.max_files {
600+
inner.prune_old_logs(max_files);
601+
}
599602
let writer = RwLock::new(create_writer(inner.log_directory.as_ref(), &filename)?);
600603
Ok((inner, writer))
601604
}

0 commit comments

Comments
 (0)