The behavior is rather well documented here.
In essence, the sink writes a log file which name is specified in the file_name
named parameter. If this parameter is a string template, the file name is re-generated every time a new file is opened.
At certain conditions, the sink may rotate the file. This means that the current file is closed and passed to the collector, if one is set. Then a new file is opened.
The collector does the file management. Upon being passed a new file, it may perform limit checks on the older files and the filesystem in the storage - the directory you provide in the target
named parameter. At this point older files may get deleted from the storage in order to fulfill the limits and be able to put the new file there as well.
It is possible to specify the storage directory in the target
parameter to be the same as the one where you write the original file (the directory from the file_name
parameter). In this case certain limits may be less reliably maintained (e.g. total file size will not include the file that is currently being written, so older files will still be deleted only upon rotation), but other than that it should still work as described.