GitHunt
OR

orangain/pretty-json-log-plugin

IntelliJ plugin to pretty print JSON lines logs.

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 configure log colors

You can configure log colors from the Settings > Editor > Color Scheme > Console
Colors
> Log console.

Settings for log colors

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.

Internal

How to release

  1. Human: Add change logs to CHANGELOG.md under the [Unreleased] section. (This step can be done when making changes.)
  2. Human: Update pluginVersion in gradle.properties and merge it into the main branch.
  3. CI/CD workflow: Create a GitHub release draft for the new version automatically.
  4. Human: Publish the release note.
  5. CI/CD workflow: Start deployment workflow automatically, but it will wait for human approval.
  6. Human: Approve deployment in Actions page.
  7. CI/CD workflow: Deploy the new version to JetBrains Marketplace and create a PR to update CHANGELOG.md.
  8. Human: Merge the PR to update CHANGELOG.md.
  9. JetBrains: The new version will be reviewed by JetBrains and if there are no problems, it will be published in Marketplace.
orangain/pretty-json-log-plugin | GitHunt