Skip to content

www.rolfje.com

How to tail a json log file

Posted on 2026-02-182026-02-19 By rolfje No Comments on How to tail a json log file

Robot-tieMany applications nowadays output json formatted log files so that they can be scraped by the newest hippest monitoring cluster (think of Splunk, Elastic Filebeat, etc). That is of course very nice and I applaud that kind of observability, but sometimes you are just on the machine fighting with a service that does not want to start, or you just want to monitor it a bit more realtime, or you just are not the browser type. Luckily there is a realatively easy trick to this.

Let’s say your logfile in /var/log/demoapp.log contains entries like:

{"@timestamp":"2026-02-18T08:56:39.391Z","log.level":"DEBUG",
"message":"Hello this is a debug message that you'd really like to see.",
"ecs.version": "1.2.0","service.name":"critical-app",
"service.version":"0.0.1-SNAPSHOT","service.environment":"acc",
"event.dataset":"ops-dataset","process.thread.name":"DefaultDispatcher-worker-2",
"log.logger":"com.rolfje.demoapp.DemoServer","device.id":"XYZ123"}

Then you can easily tail it in a readable form with stdbuf, jq and tsv, and highlight WARN and ERROR with grep:

tail -100F /var/log/demoapp.log \
| stdbuf -o0 jq -r '[."@timestamp", ."log.level", .message, .stack_trace] | @tsv' \
| cut -c 1-200 \
| grep -E --color=auto "^|WARN|ERROR"

This will output a single line per json object:

2026-02-18T08:56:39.391Z	DEBUG	Hello this is a debug message that you'd really like to see.

Bonus: You can add and trim fields in the jq arguments, for instance “(.”log.logger” // “”)[-10:]” adds the last 10 characters of the logger name if it exists.

Feel free to modify this or put it in a script.
Cheers!

Software Tags:programming, Software, Utilities

Post navigation

Previous Post: Are you de-skilling?
Next Post: Addictive Intelligence

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

         
@rolfje.com
Een Ram Van is de fatbike van de aannemer.
6 hours ago
@rolfje.com
It is ridiculous that we are building this because it should be the single most important feature in #Jira. Yet here we are and it is catching on: More and more people downloading, using and contributing to the automatically created and updated Gantt view on #Jira: github.com/rolfchess/ji...
1 day ago
@rolfje.com
www.youtube.com/shorts/qha6h...
2 days ago

Recent Comments

  • Monica Hall on Het belastinghuiswerk nagekeken
  • rolfje on Spring SystemPropertyInitializingBean
  • plinko idle clicker on Spring SystemPropertyInitializingBean
  • rolfje on The podcast problem (fixed)
  • SirenMix on The podcast problem (fixed)

Tags

Anonimatron Apple backup design DIY DRM eclipse environment fix Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Kawasaki Keynote linux modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (107)
  • Divorce (1)
  • Electronics (5)
  • Fun (58)
  • Games (8)
  • Hardware (74)
  • Microsoft (18)
  • Racing (16)
  • Software (144)
  • Uncategorized (69)
  • Workshop (23)

Archives

Brought to you without adds, banners, cookies or tracking. This one is on me. Yes, life can be this good. Pay it forward.
AI policy - Privacy policy

Copyright © 2026 www.rolfje.com.

Powered by PressBook WordPress theme