[squid-users] messages when "squid -k rotate" is run
Alex Rousskov
rousskov at measurement-factory.com
Fri Nov 22 23:29:45 UTC 2024
On 2024-11-22 12:04, Matus UHLAR - fantomas wrote:
>> On 2024-11-21 07:29, Matus UHLAR - fantomas wrote:
>>> I run squid 6 (currently 6.10) on some debian hosts.
>>>
>>> when rotating logs in the night, I get mail about cron output:
>>>
>>> 2024/11/21 00:00:41| Processing Configuration File:
>>> /etc/squid/squid.conf (depth 0)
>>> 2024/11/21 00:00:41| Processing Configuration File:
>>> /etc/squid/conf.d/debian.conf (depth 1)
>>> 2024/11/21 00:00:41| Processing Configuration File:
>>> /etc/squid/conf.d/ftplog.conf (depth 1)
>>> 2024/11/21 00:00:41| Set Current Directory to /var/spool/squid
>>> Those messages are sent to stderr, not stdout. I can imply redirect
>>> the "squid -k rotate" stderr to /dev/null
>>> but I would like to avoid it when possible - if any error happens,
>>> I't like to know about that.
> On 21.11.24 16:16, Alex Rousskov wrote:
>> If you are OK with not seeing these particular messages in cache.log
>> and on stderr, disable their level-1 reporting using cache_log_message
>> directive. The ID of those messages is 68 (see doc/debug-messages.dox
>> for IDs of other messages that can be controlled in your Squid).
> Only cache.log would be ideal.
Short answer: AFAICT, that ideal is not supported for what you want to do.
Longer answer: The following _combination_ is not supported (yet?) AFAICT:
* Sending only level-0/1 messages to cache.log,
* including a particular level-1 message.
* Sending only level-0/1 messages to stderr,
* except for a particular level-1 message.
> However, the description at
> http://www.squid-cache.org/Doc/config/cache_log_message/ is not clear
> enough what exactly that level means,
Documentation improvements are welcome! Existing cache_log_message
documentation reuses a fairly well-known "debugging level" concept that
is more-or-less described in debug_options directive documentation.
cache_log_message docs do refer to debug_options in "level=<number>"
bullet. I am sure all of this can be significantly improved.
> and unfortunately you didn't make id more clear.
I assume you meant to say "it" (i.e. "level meaning") rather than "id".
I am sorry that I failed to realize that "level" should be clarified in
this context. I should have been more careful with my assumptions!
> (the page is mentioning doc/debug-messages.txt btw)
Thank you for reporting that documentation bug. I proposed a fix at
https://github.com/squid-cache/squid/pull/1953
> Do I understand it properly that level 1 goes to stderr+cache.log and
> level 2 nowhere?
Short answer: Not quite. Assuming an error-free squid executable start
(e.g., not "squid -k"!) and default debug_options (i.e. "ALL,1"), all
level-0/1 messages go to cache.log and nothing goes to stderr. Level-2+
messages are not logged anywhere.
Longer answer:
Each message has a hard-coded debugging level. Roughly speaking, higher
levels are used for more frequent messages. Levels above 2 are meant for
developers (rather than admins). Levels above 1 are not meant for
sustained production use because they slow Squid down and generate huge
logs.
* Messages with debugging level L go to cache.log if debug_options allow
debugging level L. For example, "debug_options ALL,2" would allow
messages with debugging levels 0, 1, and 2 to be logged to cache.log.
* Messages with debugging level L that are allowed to go to cache.log
(see above) go to stderr if command line option -d allows them to go to
stderr. For example, a combination of "debug_options ALL,2" and "-d 1"
would allow messages with debugging levels 0 and 1 to be logged to stderr.
By default, in error-free cases, when running squid executable that is
supposed to (eventually) log to cache.log, nothing goes to stderr and
level-0/1 messages go to cache.log. In such cases, -d value defaults to
the equivalent of "none". To see stderr output in such cases, one has to
start squid with -d0 or higher.
When running "squid -k ..." -d defaults to 1 and nothing goes to cache.log.
Sounds complicated? There is also syslog with its own level-related
policies! :-)
HTH,
Alex.
>> For example:
>>
>> cache_log_message id=68 level=2
>> If you want Squid to only report errors to stderr, then you will need
>> to wait for (or orchestrate) the corresponding code changes.
>> Currently, Squid defines error as a message with an ERROR: or FATAL:
>> prefix. There is no Squid code to treat such messages specially though
>> (yet?). For more details, please see
>> https://github.com/squid-cache/squid/commit/d816f28de8ba817a98a49f9cfd88ddaa334d7aad
>>
>> You may be able to emulate the above error detection/handling
>> (including its risks related to incorrectly unclassified/unprefixed
>> messages) via a shell script. For example, something like this might
>> be a good starting point:
>>
>> squid -k rotate |& grep -E "FATAL:|ERROR:"
>>
>> or, with added logging of all stderr messages:
>>
>> squid -k rotate |& \
>> tee squid-last-rotate.log | \
>> grep -E "FATAL:|ERROR:"
>>
>> However, the above sketches need more work/adjustments to preserve
>> "squid -k rotate" exit status code!
>
More information about the squid-users
mailing list