Bug 89967 - RFE: journalctl custom output format like --output "%ISODATE [%-5PID] [%FOO] %MESSAGE"
Summary: RFE: journalctl custom output format like --output "%ISODATE [%-5PID] [%FOO] ...
Status: RESOLVED MOVED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-09 14:20 UTC by cb
Modified: 2016-06-07 11:04 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description cb 2015-04-09 14:20:54 UTC
It would be great if custom formats for journalctl output could be specified.

1. On the command line every paramter that is not a predefined template like "short-iso" could be parsed like a printf/slf4j/log4j format string.
Example:   journalctl --since -1d -u postfix -o "%_ISODATE [-%5_PID] (%MESSAGEID) %_PROG: %MESSAGE"

2. Both /etc/systemd/journal.conf and ~/.journal.conf could contain pre defined templates in the above syntax that are available via "--output". 
Example:   
   $ cat ~/.journal.conf
   mypostfix="%_ISODATE [-%5_PID] (%MESSAGEID) %_PROG: %MESSAGE"
   $ journalctl --since -1d -u postfix -o mypostfix

Both would encourage application developers to add custom fields like for example the Message-Id for mailer programs or a remote IP for a web server which only makes sense in for their specific log files.

Of course that could also be archived using pipes but journalctl is already has some kind of template mechanism so custom ones should be easy.
Comment 1 John Florian 2015-09-23 18:23:17 UTC
I too would love to see this.  As a developer this would allow me to stop prepending redundant info like Thread.name onto the message since I could just include the proper field in a custom format.  As it is, I must go from the default format to something like verbose which is overkill in most of my use cases.
Comment 2 Lennart Poettering 2016-06-07 11:04:44 UTC
Let's continue tracking this on github:

https://github.com/systemd/systemd/issues/3449


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.