Skip to content

Conversation

@gtenev
Copy link
Contributor

@gtenev gtenev commented Jul 8, 2019

Added 2 options:

  • proxy.config.log.rolling_allow_empty - ability to roll empty logs
    (i.e. rolling logs without traffic)
  • proxy.config.log.rolling_max_count - trimming logs to a certain
    number of rolled files on each rolling
    More info and use-cases in records.config.en.rst and rotation.en.rst.

@gtenev gtenev added the Logging label Jul 8, 2019
@gtenev gtenev added this to the 9.0.0 milestone Jul 8, 2019
@gtenev gtenev requested review from dyrock, randall and zwoop July 8, 2019 21:04
@gtenev gtenev self-assigned this Jul 8, 2019
.. ts:cv:: CONFIG proxy.config.output.logfile.rolling_allow_empty INT 0
:reloadable:

While rolling default behaviour is to rename, close and re-open the log file *only* when/if there is
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we've been using American english... so, behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

Set :ts:cv:`proxy.config.output.logfile.rolling_max_count` (yaml: `rolling_max_count`) to 1
which will lead to keeping only one rolled log file at any moment (rolled will be trimmed on every roll).

Set :ts:cv:`proxy.config.output.logfile.rolling_allow_empty` (yaml: `rolling_allow_empty`) to 1 (default: 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

extra whitespace?

allow_empty`)  to 1
             ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


Set :ts:cv:`proxy.config.output.logfile.rolling_allow_empty` (yaml: `rolling_allow_empty`) to 1 (default: 0)
which will allow logs to be open and rolled even if there was nothing to be logged during the previous period
(i.e. no requests to the traffic server).
Copy link
Contributor

Choose a reason for hiding this comment

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

to |TS|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

--------------------------------------------------

If for security reasons logs need to be purged to make sure no log entry remains on the box
for more then a specified period of time, we could achieve this by setting the following variables.
Copy link
Contributor

Choose a reason for hiding this comment

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

achieve this by setting the following variables ==>
achieve this by setting the rolling interval, the maximum number of rolled log files, and forcing |TS| to roll even when there is no traffic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@gtenev
Copy link
Contributor Author

gtenev commented Jul 10, 2019

[approve ci autest]

2 similar comments
@gtenev
Copy link
Contributor Author

gtenev commented Jul 10, 2019

[approve ci autest]

@randall
Copy link
Contributor

randall commented Jul 10, 2019

[approve ci autest]

@gtenev gtenev requested a review from bryancall July 10, 2019 23:25
long time_now = LogUtils::timestamp();

if (logfile.roll(time_now - log_object->get_rolling_interval(), time_now) == 0) {
if (logfile.roll(time_now - log_object->get_rolling_interval(), time_now)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at LogFile::roll(), return value of 1 means successful rotation? And this line should be looking for the error condition

Copy link
Contributor Author

@gtenev gtenev Jul 11, 2019

Choose a reason for hiding this comment

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

Oh, great catch! Did not mean to change this line, likely did not restore this line properly after my experiments.

std::sort(rolled.begin(), rolled.end(), [](const RolledFile a, const RolledFile b) { return a._mtime > b._mtime; });
if (rolling_max_count < rolled.size()) {
for (auto it = rolled.begin() + rolling_max_count; it != rolled.end(); it++) {
RolledFile file = *it;
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a const reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright, changing it to a const reference

A default value of 0 means auto-deletion will not try to limit the number of output logs.
See :doc:`../logging/rotation.en` for an use-case for this option.

.. ts:cv:: CONFIG proxy.config.output.logfile.rolling_allow_empty INT 0
Copy link
Contributor

Choose a reason for hiding this comment

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

I would set this to be on by default and not have a configuration option for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable to me, other solutions like i.e. multilog have similar behavior by default.

But from traffic server logging code it seems to me that someone has gone great lengths to make sure no empty log files are rolled, so having an option to enable/disable this behavior made more sense to me.

@bryancall bryancall changed the title options to roll empty logs and log trimming Options to roll empty logs and log trimming Jul 11, 2019
Added 2 options:
- proxy.config.log.rolling_allow_empty - ability to roll empty logs
(i.e. rolling logs without traffic)
- proxy.config.log.rolling_max_count - trimming logs to a certain
number of rolled files on each rolling
More info in records.config.en.rst and rotation.en.rst.
@gtenev
Copy link
Contributor Author

gtenev commented Jul 16, 2019

@bryancall, @dyrock, @mlibbey is there anything else I could address ?

@gtenev
Copy link
Contributor Author

gtenev commented Jul 16, 2019

Thank you Bryan! Merging...

@mlibbey, @dyrock thank you for your reviews as well!

@gtenev gtenev merged commit b81422a into master Jul 16, 2019
@gtenev gtenev deleted the max-life-logs branch July 17, 2019 22:09
@zwoop
Copy link
Contributor

zwoop commented Mar 19, 2020

This has merge conflicts, and we'll need a new 8.1.x PR. Also, feel free to recommend / suggest other PRs that this depends on, such that it makes the back porting easier.

@gtenev
Copy link
Contributor Author

gtenev commented Mar 24, 2020

Created PR #6553 to resolve the cherry-pick/merge conflicts.

@zwoop zwoop modified the milestones: 9.0.0, Backported Mar 26, 2020
@zwoop
Copy link
Contributor

zwoop commented Mar 26, 2020

This was back ported and merged into 8.1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants