Skip to content

orangain/pretty-json-log-plugin

Repository files navigation

Pretty JSON Log plugin

Build Version Downloads

Plugin screenshot

Pretty JSON Log plugin for IntelliJ Platform makes NDJSON (Newline Delimited JSON a.k.a. JSON Lines) logs more readable in the console. It has the following features:

  • JSON Parsing: Automatically parses each log line as JSON and extracts essential log information such as timestamp, log level, and message.
  • Colorful Display: Displays essential log information in different colors depending on the log level to make it easier to read.
  • Readable Timestamp: Formats the timestamp in a human-friendly format.
  • Expandable Pretty JSON: Prints a well-formatted JSON string following the log message. The JSON string is folded by default, but you can expand it when you need to view the full details.
  • Seamless Integration: Supports various log formats such as Logstash, Bunyan, Pino, log/slog, Cloud Logging, etc. with no additional configuration or software.

This plugin is useful when you are developing a modern system that outputs logs in JSON format. You no longer need to switch log formats between production and local development environments.

Installation

  • Using the IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "Pretty JSON Log" > Install

    Installation dialog

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

After installation, newly written JSON lines logs in the console will be automatically formatted by the plugin.

Limitations

JetBrains IDEs provide different kinds of consoles for different run configurations, but this plugin does not currently support all consoles due to the lack of extension points in the IDE. If the console does not have the context menu item "Pretty JSON Log", the plugin is not supported in that console.

Context menu item with text 'Pretty JSON Log'

How to see the debug log of the plugin

  1. Help > Diagnostic Tools > Debug Log Settings....
  2. Add line #io.github.orangain.prettyjsonlog to the text area of the dialog and click OK.
  3. Reproduce the issue.
  4. Help > Show Log in Finder/Explorer to open the log directory.
  5. Open the idea.log file and find the log of the plugin by searching for #io.github.orangain.prettyjsonlog.

Enabling debug logging may slow down the IDE, so it is recommended to disable it after reproducing the issue.

Acknowledgements

This plugin is inspired by the pino-pretty and bunyan CLI. The great idea behind these tools is that applications should write logs in machine-readable format (JSON) and pretty-printing for human readability should be done by another tool. I am grateful to the authors of these tools.

Thanks to the IntelliJ Platform Plugin Template, I was able to quickly start developing the plugin.