brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl _TRANSPORT=stdout shows what services printed to their terminal

Journalctl
~/tips/tip-journalctl-transport-stdout

journalctl _TRANSPORT=stdout -u myapp

Separate the lines a service printed with echo or print from its proper log calls.

Every line in the journal carries a _TRANSPORT field that says how it arrived. I find that handy when a service mixes real log calls with stray prints.

The common values are journal (native journal API), syslog (the syslog socket, which is what logger uses), stdout (standard output or error of a service), kernel and audit. So this shows only what a unit wrote to stdout or stderr:

journalctl _TRANSPORT=stdout -u myapp

A quick test with a unit that ran echo out-line; echo err-line >&2 gave exactly those two lines, while the Starting and Started messages from systemd were gone, because those arrive over the journal transport.

The opposite is useful too. A Python app that logs properly but also has a stack trace or two in its output can be split like this:

journalctl -u myapp _TRANSPORT=journal
journalctl -u myapp _TRANSPORT=stdout

Stdout and stderr share the same transport, so you can not tell them apart with this field. If you need that, set StandardError= in the unit to send stderr somewhere else, or give it its own identifier with SyslogIdentifier=.

Further reading: systemd.journal-fields man page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link