1

When text_file_backend is set used and collector is set, are log files created in keywords::target directory or does collector move old log files there?

If collector moves them, when does collector do it, immediately after old log file is closed and new is created or in some other moment?

Again, if collector moves them at some moment, new log file (or files) is in one place and old log files are in another place. Assuming that I want collector to delete very old files, is there a way to leave log files in the same place where they were created but delete very old files?

George Sovetov
  • 4,942
  • 5
  • 36
  • 57

1 Answers1

3

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.

Andrey Semashev
  • 10,046
  • 1
  • 17
  • 27
  • You just assured me that it's OK to have collector target same as original log files directory. That's what I needed in the end. Also, it's pleasure to get answer from author of library I asked about. Thanks! – George Sovetov Mar 28 '16 at 18:18