Score:0

How do I stop journald from dropping blank lines?

ng flag

I have an application which logs to stdout in a format like this:

incoming request from x.x.x.x
client version is 1.2
authenticated as [email protected]
processed 1234 bytes
closing connection

rejecting connection from y.y.y.y
client subnet is not on the list of allowed subnets

incoming request from z.z.z.z
client version is 1.6
authenticated as [email protected]
WARN: {{lang}} is not set for [email protected]
processed 2345 bytes
closing connection

As you can imagine, the blank lines make this format much easier to read. When I run this as a systemd service and look at the output with journalctl -fu, it appears newlines are being dropped. How do I prevent that from happening?

Score:0
in flag

I am not sure which version you are using or if any filter applied but for journalctl default output is short

short : is the default and generates an output that is mostly identical to the formatting of classic syslog files, showing one line per journal entry.

if you want output in different format you need use -o option and supply field as desired. Hope this will help you. From manual pasting below section.

       -o, --output=
       Controls the formatting of the journal entries that are shown. Takes one of the following options:

       short
           is the default and generates an output that is mostly identical to the formatting of classic syslog files, showing one line
           per journal entry.

       short-iso
           is very similar, but shows ISO 8601 wallclock timestamps.

       short-precise
           is very similar, but shows timestamps with full microsecond precision.

       short-monotonic
           is very similar, but shows monotonic timestamps instead of wallclock timestamps.

       verbose
           shows the full-structured entry items with all fields.

       export
           serializes the journal into a binary (but mostly text-based) stream suitable for backups and network transfer (see Journal
           Export Format[1] for more information).

       json
           formats entries as JSON data structures, one per line (see Journal JSON Format[2] for more information).

       json-pretty
           formats entries as JSON data structures, but formats them in multiple lines in order to make them more readable by humans.

       json-sse
           formats entries as JSON data structures, but wraps them in a format suitable for Server-Sent Events[3].

       cat
           generates a very terse output, only showing the actual message of each journal entry with no metadata, not even a timestamp.
9072997 avatar
ng flag
`--version` shows `systemd 249 (249.7-1)`. Even running `journalctl -fu myservice -o verbose` it looks like there are not messages generated for blank lines.
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.