Why does journalctl prefix duplicate output with "ANSWER"? #681
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#681
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why does journalctl duplicate Borgmatic's output lines prefixed with "ANSWER"?
The ANSWER lines in my terminal are a yellow-green color. The rest of the lines are the normal color.
Searching with
journalctl --grep ANSWER
shows only Borgmatic output.My Borgmatic config looks like this:
Here is my service file at
~/.config/systemd/user/borgmatic.service
:And here is my timer file at
~/.config/systemd/user/borgmatic.timer
:I searched Google for both
borgmatic ANSWER
andjournalctl ANSWER
, but didn't see anything useful.Environment
borgmatic version: 1.7.10
borgmatic installation method: pipx
Borg version: 1.2.4
Python version: 3.8.10
operating system and version: Ubuntu 20.04.5 LTS
The reason you're getting double logs is because borgmatic is logging once to stdout and once directly to syslog/journald. The
ANSWER
lines are those logs that go direct to syslog, andANSWER
is the log level for a particular log (e.g.,WARN
,INFO
,DEBUG
, etc.).My recommendation is to tweak the borgmatic flags in your systemd serivce to be more similar to the sample systemd service file. Specifically, reduce the stdout logging and increase the syslog verbosity:
Example:
This means that stdout will log errors only and syslog/journald will log up to
INFO
level (so, everything exceptDEBUG
logs).Note that there's an open pull request that would allow disabling stdout logging entirely.
Let me know if you have any other questions on this!
EDIT: The pull request has been merged and released as part of #484 and borgmatic 1.7.14, so if you're using that version or higher, do this to even disable errors to stdout:
I took your advice on the flags. Now there are no more duplicate messages in the journal.
That solves the main problem. Thanks for your clear explanation.
Is
ANSWER
a real log level? I don't see it mentioned in the syslog documentation.The word
ANSWER
and everything following in the line still appears in green. It makes me think it's something else with special handling in systemd or syslog.It's a custom log level used only by borgmatic. Its purpose is to allow borgmatic to respond to user requests like
list
orinfo
even when the--verbosity
level is low (0).I believe borgmatic only colors output sent to stdout, so my guess is that journalctl is choosing to color output based on the log level. From the journalctl documentation: "When outputting to a tty, lines are colored according to priority: lines of level ERROR and higher are colored red; lines of level NOTICE and higher are highlighted; lines of level DEBUG are colored lighter grey; other lines are displayed normally."
Yes, journalctl seems to color the output according to its log level.
My guess is that Borgmatic's ANSWER log level is equivalent to a warning.
Here's a screenshot of how I see the different log levels.
The ANSWER lines all look like that green/yellow line.
I've annotated the text version with how each message is painted.
To generate that I used systemd-cat to write some test messages to the journal.
This script sets
p
to each of the documented log levels. systemd-cat uses the level to write a message identifying itself as LogTest.In another terminal I watch for messages from LogTest.
This now answers all my initial questions and satisfies my curiosity, so I'll close the issue. Thanks for your support!
Sure thing!