12

I have to refer large logs everyday(>20K lines).

Sometimes there are JSONs in the logs. These JSONs are HUGE(>3-5K lines) These impact the readability of the logs - making them very difficult to read.

I am looking for a free, preferably open-source log viewer which can help me deal with these JSONs - just simple operations like colour encoding and collapsing(I really need this) will be of great help to improve the readability.

Can someone please suggest something.

1
  • How to distinguish in these logs what should be treated as JSON (as basically any number is valid JSON by itself) and what shouldn't? Any log example?
    – TMSZ
    Jan 11, 2018 at 13:38

4 Answers 4

2

Found this free library on GitHub which I had used earlier. Log viewer converts the patch of text into individual blocks of json data for easy viewing of large logs of json files. Additionally the log viewer has various search functionality which is useful for such large logs debugging/extracting information. Software is distributed under MIT license.

JSON Log Viewer

Sample snapshot

2
  • Please add some text explaining why this would help the OP. This is currently just a link-only answer and will probably get deleted.
    – user416
    Oct 21, 2018 at 11:08
  • This tool is nice, but does not support tail or reload (not watch nor manual reload) and has a single config for all log files. It doesn't look like it's being actively maintained, but it does offer a nice column view and works quite well if you don't require those things. Feb 18, 2020 at 21:23
1

You can visualize JSON log at console very easily with munia-pretty-json and there are many options to filter and color the JSON keys.

Your json data (app-log.json)

{"time":"2021-06-09T02:50:22Z","level":"info","message":"Log for pretty JSON","module":"init","hostip":"192.168.0.138","pid":123}
{"time":"2021-06-09T03:27:43Z","level":"warn","message":"Here is warning message","module":"send-message","hostip":"192.168.0.138","pid":123}

Run the command:

munia-pretty-json app-log.json

Here is readable output:

2021-06-09T02:50:22Z info Log for pretty JSON
2021-06-09T03:27:43Z warn Here is warning message

You can format the output with the template. The default template is '{time} {level -c} {message}'

Using template:

munia-pretty-json -t '{level} - {message} - {module}' app-log.json

Output:

info - Log for pretty JSON - init
warn - Here is warning message - send-message
0

Not really free but really affordable is JSONBuddy. It has built-in grid and text views and can work with large data as well. It also has syntax-coloring and collapsing. enter image description here

0

Below command makes use of jq and prints java stack traces correctly. Tested on json log files generated by logback

cat app-log.json | grep "^{"  |  jq -r '"\(."@timestamp")\t\(.level)\t\(.message)\n\(.stack_trace)"' | grep -v "^null" | sed -e 's/\\n/\n/g' -e 's/\\t/\t/g' | less
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 28 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.