diff --git a/lib/src/outputs/advanced_file_output.dart b/lib/src/outputs/advanced_file_output.dart index ab866914..f9226c86 100644 --- a/lib/src/outputs/advanced_file_output.dart +++ b/lib/src/outputs/advanced_file_output.dart @@ -179,10 +179,10 @@ class AdvancedFileOutput extends LogOutput { await _file.length() > _maxFileSizeKB * 1024) { // Rotate the log file await _closeSink(); - await _file.rename('$_path/${_fileNameFormatter(DateTime.now())}'); + await _file.copy('$_path/${_fileNameFormatter(DateTime.now())}'); await _deleteRotatedFiles(); - // Reset file ref to "latest" - _file = maxFileSizeKB > 0 ? File('$path/$latestFileName') : File(path); + // Clear contents of "latest" + await _file.writeAsString("", mode: FileMode.write, flush: true); await _openSink(); } } catch (e, s) {