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
    Commented Jan 11, 2018 at 13:38

5 Answers 5

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
    Commented 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. Commented 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
1

For those looking for a log viewer with JSON support, I highly recommend json-log-viewer.

json-log-viewer

json-log-viewer is an efficient and user-friendly tool that offers the following features:

  1. Native JSON Support: It is specifically designed to handle JSON log files, providing a clear and structured view of the data.
  2. Intuitive User Interface: The interface is straightforward and easy to navigate, allowing users to quickly filter and search within logs.
  3. Color-Coded Formatting: Logs are displayed with color-coded formatting, making it easy to read and distinguish different log levels (info, warning, error, etc.).
  4. Advanced Filters and Search: It offers advanced filtering options and search capabilities to focus on specific data within the logs, which is particularly useful for detailed analysis.
  5. Multi-Platform Support: Compatible with Windows, macOS, and Linux, ensuring you can use it in any work environment.
  6. Free Online Version: There is even a free online version available at json-log-viewer online, which allows you to use the tool without any installation.
  7. Open Source: As an open-source project, you can contribute to its development or customize it to fit your specific needs.
  8. Part of a Larger Project: Since it is part of a larger project, its maintenance and updates are likely to be more frequent.

I hope you find it useful!

New contributor
David Goitia is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
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
    Commented Jun 28, 2023 at 17:12

Your Answer

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

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