Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file_name cannot end with a %pattern for collector to work #78

Closed
pulver opened this issue Mar 30, 2019 · 3 comments

Comments

@pulver
Copy link

commented Mar 30, 2019

When initializing a sinks::text_file_backend, an attached collector won't delete files that exceed max_files unless the file_name ends with a static (non-pattern) character.

This works fine:
keywords::file_name = "logs/file.%Y%m%d-%H%M%S.log"
but this doesn't:
keywords::file_name = "logs/file.%Y%m%d-%H%M%S"
in that any number of files in the second case can exist, beyond the limit set by the collector's max_files.

@pulver pulver changed the title file_name requires static extension for collector to work file_name cannot end with a %pattern for collector to work Mar 30, 2019

@Lastique

This comment has been minimized.

Copy link
Member

commented Mar 31, 2019

I can't reproduce it with example/rotating_file. Can you provide a small compilable code sample that shows the problem?

@pulver

This comment has been minimized.

Copy link
Author

commented Mar 31, 2019

  1. Start with boost_1_70_0/libs/log/example/doc/sinks_xml_file.cpp.

  2. Change keywords::max_files = 512 to keywords::max_files = 3.

  3. Compile and run: g++ sinks_xml_file.cpp -lboost_log -lboost_thread -lpthread -lboost_filesystem -DBOOST_LOG_DYN_LINK ; ./a.out ; ls logs

  4. 3 files show up, as expected: 20190331_082025_00008.xml 20190331_082025_00009.xml 20190331_082025_00010.xml

  5. Run ./a.out again. 3 files are in logs and old ones were deleted as expected.

  6. rm -Rf logs

  7. Change keywords::file_name = "%Y%m%d_%H%M%S_%5N.xml" to keywords::file_name = "%Y%m%d_%H%M%S_%5N"

  8. Compile and run.

  9. 3 files show up again, as expected: 20190331_082132_00008 20190331_082132_00009 20190331_082132_00010

  10. Run ./a.out again. 6 files are in logs. 3 are expected.

  11. Run ./a.out again. 9 files are in logs. 3 are expected.

  12. ...

@Lastique Lastique closed this in d7a8711 Apr 14, 2019

@Lastique

This comment has been minimized.

Copy link
Member

commented Apr 14, 2019

Should be fixed in d7a8711, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.