Skip to content

Rotated squid.log files have hostname coming from request #7922

Closed

Description

@lukenowak

My etc/trafficserver/logging.yaml is:

formats:
  - name: squid
    format: '%<cqtq> %<ttms> %<chi> %<crc>/%<pssc> %<psql> %<cqhm> %<cquc> %<cluc> %<caun> %<phr>/%<shn> %<psct>'
logs:
  - filename: squid
    format: squid
    mode: ascii
    rolling_enabled: 1
    rolling_interval_sec: 10
    rolling_offset_hr: 0

(the small rolling_interval_sec is to see the issue) and I see that it uses rotated filename like:

squid.log_www.example.com.20210604.10h28m50s-20210604.10h29m30s.old

Where www.example.com is just on of sites being served via Trafficserver.
Instead of usual:

squid.log_HOST.IP.V.4.20210604.10h28m50s-20210604.10h29m30s.old
(it was like with with ATS 8).

I tried to set:

CONFIG proxy.config.log.hostname STRING justit
To have:

squid.log_justit.20210604.10h28m50s-20210604.10h29m30s.old

But it seemed to be ignore during rotation.

The rest of config.log from records.config are:

CONFIG proxy.config.log.logging_enabled INT 3
CONFIG proxy.config.log.max_space_mb_for_logs INT 25000
CONFIG proxy.config.log.max_space_mb_headroom INT 1000
CONFIG proxy.config.log.rolling_enabled INT 1
CONFIG proxy.config.log.rolling_interval_sec INT 86400
CONFIG proxy.config.log.rolling_size_mb INT 10
CONFIG proxy.config.log.auto_delete_rolled_files INT 1
CONFIG proxy.config.log.periodic_tasks_interval INT 5

Which are correctly overridden in etc/trafficserver/logging.yaml

Trafficserver version used is 9.0.1

Activity

  1. bneradt commented on Jun 15, 2021

    @bneradt
    Contributor

    Thank you for filing the issue. I'll look into this.

    In case it's helpful, starting from 9.1.x, ATS supports external log rotation utilities (such as logrotate) via the SIGUSR2 signal:
    https://docs.trafficserver.apache.org/en/9.1.x/appendices/command-line/traffic_manager.en.html?highlight=sigusr2#signals

    Thus, logrotate can be configured to rotate the logs and send a SIGUSR2 to the traffic_manager process which will then re-open its file descriptors. We (Yahoo!) are using logrotate and SIGUSR2 to handle log rotation.

    I mention this in case it's helpful to plan ahead for when you move to 9.1.x. In the meantime I'll look into the issues you reported here.

  2. bneradt commented on Jun 15, 2021

    @bneradt
    Contributor

    Hi @lukenowak,

    I created a PR to address the issue where proxy.config.log.hostname is not respected when rotating the logs. That is indeed a bug and should be fixed with PR #7943.

    In addition to proxy.config.log.hostname not being respected, you also mention that the default hostname used for the rotated logs changed from an IP address to the hostname of the machine between 8.x and 9.x. Is that an issue for you, or were you simply making an observation? That is, if #7943 is merged in and proxy.config.log.hostname is respected for the rotated logs, will that be a sufficient fix for you?

  3. lukenowak commented on Jun 16, 2021

    @lukenowak
    Author

    If I'll be able to use proxy.config.log.hostname then the default hostname change is not a problem for me anymore, just having #7943 is good enough, thanks.

  4. lukenowak commented on Jun 16, 2021

    @lukenowak
    Author

    I mention this in case it's helpful to plan ahead for when you move to 9.1.x. In the meantime I'll look into the issues you reported here.

    That's excellent news, as soon as 9.1.x will be out I'll be happy to use it with logroration.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions