[systemd-devel] Testing LogFilterPatterns= on user-level services
Farblos
AKFKQU.9DF7RP at vodafonemail.de
Fri Jan 12 13:44:54 UTC 2024
Hi.
I'm playing with the LogFilterPatterns= directive on user-level
services, not very successfully so far.
[~]$ systemd --version
systemd 255 (255.2-3)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
Here is my testcase for a user-level service illustrating my
problem:
Create a file /tmp/test.sh with the following contents:
------------------------- test.sh -------------------------
while :; do
echo ritzelbimpf
echo ritzelbimpf | logger
echo ritzelbimpf | systemd-cat
echo foobarbaz
echo foobarbaz | logger
echo foobarbaz | systemd-cat
sleep 10
done
------------------------- test.sh -------------------------
Create a user-level service in file
~/.config/systemd/user/test.service with the following contents:
------------------------- test.service -------------------------
[Unit]
Description=test service
[Service]
ExecStart=/bin/bash /tmp/test.sh
LogFilterPatterns=~ritzelbimpf
------------------------- test.service -------------------------
Then execute:
[~]$ systemctl --user daemon-reload
[~]$ systemctl --user start test.service
[~]$ systemctl --user stop test.service
This results in the following messages in the journal for me:
------------------------- test.service -------------------------
Jan 12 14:36:30 host01 systemd[1377]: Reloading...
Jan 12 14:36:30 host01 systemd[1377]: Reloading finished in 69 ms.
Jan 12 14:36:37 host01 systemd[1377]: Started test.service - test service.
Jan 12 14:36:37 host01 bash[3372]: ritzelbimpf
Jan 12 14:36:38 host01 farblos[3374]: ritzelbimpf
Jan 12 14:36:38 host01 cat[3376]: ritzelbimpf
Jan 12 14:36:38 host01 bash[3372]: foobarbaz
Jan 12 14:36:38 host01 farblos[3379]: foobarbaz
Jan 12 14:36:38 host01 cat[3381]: foobarbaz
Jan 12 14:36:45 host01 systemd[1377]: Stopping test.service - test service...
Jan 12 14:36:45 host01 systemd[1377]: Stopped test.service - test service.
------------------------- test.service -------------------------
That is, these "ritzelbimpf" messages come through unfiltered.
What am I missing here?
And: If my approach is fundamentally flawed, how would a minimal
test case for a user-level service look like that demonstrates
how/that LogFilterPatterns= works?
Thanks!
More information about the systemd-devel
mailing list