[GH-ISSUE #1063] log-level-overrides does not permit spaces in value string #744

Open
opened 2026-05-07 00:27:06 +02:00 by BreizhHardware · 1 comment

Originally created by @patanne on GitHub (Mar 21, 2024).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1063

I would like to leave the logging level of the server on INFO. However having an entry for server stats every hour is a little too much noise. So for "server stats" I want to set the level to WARN. The log-level-overrides entry should be this, but doing so causes the server load to fail:

"message=Server stats -> warn"

In digging through the code I found the following regex in ntfy/cmd/app.go, line 31:

(?i)^([^=\s]+)(?:\s*=\s*(\S+))?\s*->\s*(TRACE|DEBUG|INFO|WARN|ERROR)$

The culprit is "\S+". Changing the regex to this works, if this is a bug:

(?i)^([^=\s]+)(?:\s*=\s*(.+))?\s*->\s*(TRACE|DEBUG|INFO|WARN|ERROR)$

You as the authors of the code may have done this on purpose because multiple words (and the whitespace that comes with them) could break search logic deeper in the code. Is this a bug or a choice?

Originally created by @patanne on GitHub (Mar 21, 2024). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1063 I would like to leave the logging level of the server on INFO. However having an entry for server stats every hour is a little too much noise. So for "server stats" I want to set the level to WARN. The log-level-overrides entry should be this, but doing so causes the server load to fail: **`"message=Server stats -> warn"`** In digging through the code I found the following regex in ntfy/cmd/app.go, line 31: **`(?i)^([^=\s]+)(?:\s*=\s*(\S+))?\s*->\s*(TRACE|DEBUG|INFO|WARN|ERROR)$`** The culprit is "**\S+**". Changing the regex to this works, if this is a bug: **`(?i)^([^=\s]+)(?:\s*=\s*(.+))?\s*->\s*(TRACE|DEBUG|INFO|WARN|ERROR)$`** You as the authors of the code may have done this on purpose because multiple words (and the whitespace that comes with them) could break search logic deeper in the code. Is this a bug or a choice?
Author
Owner

@mpeter50 commented on GitHub (May 1, 2024):

This issue is even worse in the default configuration, where the long line of statistics is printed to the log every minute.

While the server stats log messages cannot be filtered, an other option is to set the manager-interval config value.
The docs say this about it:

Interval in which the manager prunes old messages, deletes topics and prints the stats.

The default value of it is 1 minute, but if you increase it to an hour or a day, it might be less of a problem.
Actually, for me filtering the messages would have been the workaround, this (less frequent stats logging) is the solution I was looking for.

If you make use of this, don't forget that this also affects the execution of cleanup operations.

<!-- gh-comment-id:2088396972 --> @mpeter50 commented on GitHub (May 1, 2024): This issue is even worse in the default configuration, where the long line of statistics is printed to the log every minute. While the server stats log messages cannot be filtered, an other option is to set the `manager-interval` config value. The [docs](https://docs.ntfy.sh/config/) say this about it: > Interval in which the manager prunes old messages, deletes topics and prints the stats. The default value of it is 1 minute, but if you increase it to an hour or a day, it might be less of a problem. Actually, for me filtering the messages would have been the workaround, this (less frequent stats logging) is the solution I was looking for. If you make use of this, don't forget that this also affects the execution of cleanup operations.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#744
No description provided.