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

Fix the RotatingFileHandler configuration of the daemon logger #3891

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 3, 2020

Fixes #3557

The logging configuration for the daemon did already include the
definition of a RotatingFileHandler, however, the logs were not
actually being rolled over when the maximum size was hit. The problem
was because the argument backupCount was not defined. As the python
documentation of the logging module states:

but if either of maxBytes or backupCount is zero, rollover never
occurs, so you generally want to set backupCount to at least 1,
and have a non-zero maxBytes.

Setting backupCount to 10, fixes the problem. The size of each file is
set to 10 MB. This should then keep at most 100 MB of log files for each
profile.

The logging configuration for the daemon did already include the
definition of a `RotatingFileHandler`, however, the logs were not
actually being rolled over when the maximum size was hit. The problem
was because the argument `backupCount` was not defined. As the python
documentation of the `logging` module states:

  but if either of `maxBytes` or `backupCount` is zero, rollover never
  occurs, so you generally want to set `backupCount` to at least 1,
  and have a non-zero `maxBytes`.

Setting `backupCount` to 10, fixes the problem. The size of each file is
set to 10 MB. This should then keep at most 100 MB of log files for each
profile.
@sphuber sphuber requested review from giovannipizzi and ltalirz April 3, 2020 12:51
Copy link
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving, even if there is the risk that huge logs end up deleting all the history? Anyway I think the log often are mostly useful while noticing the problem, not much later.
Is this configurable, maybe?

@ltalirz
Copy link
Member

ltalirz commented Apr 3, 2020

Right - one question in general would be what should determine the maximum size of a file.
If I understand correctly, then the reason we introduce backup files here is because it is needed to have a file size limit at all.

In that sense, a backup count of 1 would do the job as well.

@greschd
Copy link
Member

greschd commented Apr 3, 2020

Right - one question in general would be what should determine the maximum size of a file.
If I understand correctly, then the reason we introduce backup files here is because it is needed to have a file size limit at all.

I think it is to have some granularity in how the backup is rolled. More, smaller, files mean that the amount of history deleted at a time is smaller for the same total log size. So the fluctuations in how much history is currently available at any given time are smaller.

@codecov
Copy link

codecov bot commented Apr 3, 2020

Codecov Report

Merging #3891 into develop will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3891   +/-   ##
========================================
  Coverage    77.17%   77.17%           
========================================
  Files          457      457           
  Lines        33778    33778           
========================================
  Hits         26067    26067           
  Misses        7711     7711           
Flag Coverage Δ
#django 69.21% <ø> (ø)
#sqlalchemy 70.03% <ø> (ø)
Impacted Files Coverage Δ
aiida/common/log.py 94.33% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 434c593...05ff94d. Read the comment docs.

@sphuber
Copy link
Contributor Author

sphuber commented Apr 3, 2020

I will merge this now and if there really is a need to make these values configurable, we can open a feature request issue to have support added for this through verdi config

@sphuber sphuber merged commit ef59281 into aiidateam:develop Apr 3, 2020
@sphuber sphuber deleted the fix/3557/daemon-log-rotating-file branch April 3, 2020 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rotating log file handlers for the daemon log
4 participants