Score:0

How do I disable logging from systemd when I login

gt flag

My journald log contains lots of messages of this kind:

Jun 03 11:38:37 test1 systemd[225427]: pam_unix(systemd-user:session): session opened for user user(uid=1000) by (uid=0)
Jun 03 11:38:37 test1 systemd[225427]: Queued start job for default target Main User Target.
Jun 03 11:38:37 test1 systemd[225427]: Reached target Paths.
Jun 03 11:38:37 test1 systemd[225427]: Reached target Sockets.
Jun 03 11:38:37 test1 systemd[225427]: Reached target Timers.
Jun 03 11:38:37 test1 systemd[225427]: Reached target Basic System.
Jun 03 11:38:37 test1 systemd[225427]: Reached target Main User Target.
Jun 03 11:38:37 test1 systemd[225427]: Startup finished in 45ms.
Jun 03 11:40:24 test1 systemd[225427]: Stopped target Main User Target.
Jun 03 11:40:24 test1 systemd[225427]: Stopped target Basic System.
Jun 03 11:40:24 test1 systemd[225427]: Stopped target Paths.
Jun 03 11:40:24 test1 systemd[225427]: Stopped target Sockets.
Jun 03 11:40:24 test1 systemd[225427]: Reached target Shutdown.
Jun 03 11:40:24 test1 systemd[225427]: Stopped target Timers.
Jun 03 11:40:24 test1 systemd[225427]: systemd-exit.service: Succeeded.
Jun 03 11:40:24 test1 systemd[225427]: Finished Exit the Session.
Jun 03 11:40:24 test1 systemd[225427]: Reached target Exit the Session.

I think they happen whenever my deploy script executes a command through SSH. These messages are useless and pollute my log. How do I disable them?

I prefer not to get any messages at all when things go right and only be notified of errors.

This is a Debian system.

Score:1
fr flag
anx

I prefer not to get any messages at all when things go right

Do not display "things did go right" level warning then. Select your floor with the --priority=[0-7] switch, where 0 refers to emergencies and levels 5,6,7 are notice, info, debug messages, generally not indicating problems.

You can also chose standard time format and ignore non-system entries - or a combination of all three:

journalctl -o short-iso-precise --system -p 4

Where this is still insufficient, pipe that through an appropriate grep -Evf ignore.regex call, and please file bug reports with your distribution whenever you run into messages with unjustified warning/error level.

These messages are useless and pollute my log

These are not even the most useless in your logs. These are properly timestamped, clearly attributed and legible. They are going to help you when you inevitable run into one of the actually useless ones - when you are trying to diagnose something and need context.

My apps are perfectly well behaved. They only log what they need to log and what I want to see.

This aligns well with the notion of assigning levels to log entries of varying importance. In this case, all their logs shall be treated as high-level. To express that in their respective unit files, use SyslogLevel=3.

I don't believe systemd is even capable of performing

I don't think performance is what gives Microsoft this sort of market dominance.

jurgen avatar
gt flag
The -o flag only changes the layout of the time. Doesn't matter that much. The --system flag can't be used since it would filter out user services. I need to see all messages that occur not filter stuff. -p I don't believe systemd is even capable of performing. How would systemd know that a message is info or notice in my custom app? Grepping is also not an option. Filtering messages is too dangerous, I don't want to accidentally miss stuff. It also makes the log aggregator brittle. I need to know which config file to change so that the messages don't get generated in the first place.
anx avatar
fr flag
anx
You would never be truly finished changing *all the other* moving parts of your system. Rather, change your application to improve its logging - if it does not speak any journal/syslog protocol, but does output lines like `level: message` lines to stderr, consider `StandardError=journal` with `SyslogLevel=3` and/or log format appropriate for `SyslogLevelPrefix=true` (documented in `man systemd.exec`).
jurgen avatar
gt flag
My apps are perfectly well behaved. They only log what they need to log and what I want to see. My problem is with the software that is running the server itself. I'm getting spurious logging from sshd, systemd-logind, systemd, and pam. Will I be fiddling with this for a while? Yeah, probably. And it looks like filtering will be unavoidable in the end. I'm still thinking about the proper place for it.
anx avatar
fr flag
anx
That only makes it easier. If your applications exclusively log high-level messages, then just statically configure that high log level, done.
anx avatar
fr flag
anx
Just to give you an idea how much work it is to tame all other OS components (instead of only your own applications), I did assemble myself a filter list to remove uninteresting warnings from my notifications, I am at 5565 rules now, and that does not even include outstanding work for the next OS release.
jurgen avatar
gt flag
I found a decent enough place to add filtering. Not using grep but somewhere else. And so far I'm up to about 15 regular expressions to filter out left over junk from various services. The regexs are fairly strict so I'm not worried about false positives. 5565 seems like an awfully large number of filters. I'm already down to just a few messages, so I doubt the list will grown much.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.