News for hackers. Stuff that matters.
Re:Lnav – An advanced log file viewer for the small-scale by 10987654321 on Friday January 06, 2023 @05:41AM (#34273200)
Another benefit with json/logfmt that bears mentioning explicitly: it has structure.

This means that you shouldn't just write (to reuse the previous example):

    msg="Request for user [email protected] finished with status 200"
you should do it like

    msg="Request finished" status=200 [email protected]
and not put any variables into the msg key (and not really do advanced formatting for any of the keys for that matter). This way once you get it put into a log system that understands your format you can do searches like "all log messages where user=foo" or "all statuses that are >=500 and <600" or search on specific messages, all without having to craft elaborate regular expressions and with better performance since the log search system can do indexing and various optimizations so that it doesn't have to be a full-text search every time.

There are no comments on this comment yet.