Score:2

Telling journalctl to show all but a certain facility

cn flag

I'm trying to get rid of dhcpd spam in my journal.

Using rsyslog.conf and dhcpd.conf I have been able to keep it out of /var/log/syslog and put it in /var/log/dhcpd.log which is great.

However, journalctl will still show the dhcpd spam.

How do I instruct journalctl to use an "everything-but-X" filter?

I don't want to type

$ journalctl --facility=kern,user,mail,....,local7

But invert the logic to something like:

$ journalctl --facility=!local7

But that latter syntax is incorrect. Is there a way to achieve this? Or else, filter on !dhcpd or something?

Raffa avatar
jp flag
AFAIK it doesn't support negation ... However, you can filter with e.g. `... | grep -v "word" | less`
Bram avatar
cn flag
@raffa Thank you. Once piped through another program, the log loses all colour encodings. So no longer red errors, yellow warnings. I need the option in systemctl itself.
Score:0
jp flag

Unfortunately, journalctl doesn't seem to support that kind of excluding output by negating a certain facility.

Possible workarounds are:

  • Using grep with the -v, --invert-match option like so:

    journalctl | grep --line-buffered -v 'pattern'
    
  • Using grep with ccze(needs install) log colorizer for color coded output like so:

    journalctl | grep --line-buffered -v 'pattern' | ccze -A
    
  • Using journalctl builtin -g, --grep= option with PCRE2 regular expressions pattern to filter entries by the message field like so:

    journalctl --grep='pattern'
    

    This one will be tricky to negate a string, but your best bet might be to include negative lookarounds.

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.