orangain / pretty-json-log-plugin

IntelliJ plugin to pretty print JSON lines logs.
https://plugins.jetbrains.com/plugin/24693-pretty-json-log
MIT License
6 stars 3 forks source link

Support for Rider & Serilog JSON #53

Closed Twinki14 closed 1 week ago

Twinki14 commented 1 month ago

Sadly, this doesn't appear to work out-of-the-box in Rider apps that use Serilog to output JSON logs,

rider64_btaR9Pg80U
orangain commented 1 month ago

@Twinki14 Thank you for reporting the issue!

There could be two cases why the plugin does not work:

  1. Rider's console does not support the plugin.
  2. The plugin does not work with Serilog's output for some reason.

To determine the cause, could you please check the debug log of the plugin by the steps in README?

It would be helpful if you could share the log that contains #io.github.orangain.prettyjsonlog.console here.

Twinki14 commented 1 month ago

Sure, idea.log

Note, in Rider enabling the debug level was slightly different:

Help -> Diagnostic Tools -> Choose Trace Scenarios -> Advanced log settings

orangain commented 1 month ago

@Twinki14 Thank you for sharing the log. Unfortunately, it seems that Rider does not support the plugin. According to the log, the plugin works at build time, but not at run time.

While investigating the issue, I found a report of the Grep Console plugin not working with Rider ^1. That plugin uses the same extension points as the Pretty JSON Log plugin.

Currently, there does not seem to be no way to get the plugin to work with Rider until JetBrains provides extension points for Rider's console ^2.

Sorry for the inconvenience. Once again, thank you for trying the plugin and reporting the issue.

Twinki14 commented 1 week ago

Happy to report that in the latest Rider version, 2024.2.3, it appears this plugin now picks up and modifies the Rider console correctly, however the console output looks like

[null] null: null 
{
  "@i": "e8bfc543",
  "@m": "Using AWS credentials specified with the AWSOptions.Credentials property",
  "@t": "2024-09-04T17:11:26.7805905Z",
  "SourceContext": "AWSSDK"
}

rider64_iIAVM9nqpY

Seems maybe an issue with supporting Serilog?

orangain commented 1 week ago

@Twinki14 That's a good news! I would add support for Serilog this weekend.

However, I could not reproduce the plugin working in my environment (Rider 2024.2.3, macOS 14.6.1, Trial License). Maybe some setting or condition changes the behavior.

Twinki14 commented 1 week ago

@Twinki14 That's a good news! I would add support for Serilog this weekend.

However, I could not reproduce the plugin working in my environment (Rider 2024.2.3, macOS 14.6.1, Trial License). Maybe some setting or condition changes the behavior.

After digging deeper it looks like when debugging a project the debugger console is completely seperate than when running a project on it's own. The debugger console looks to be totally compatible with this plugin.

So, to recreate it, use a blank console project and debug it. It's also worth noting Serilog output is done in several different popular configurations.

https://github.com/serilog/serilog-formatting-compact is the most popular and has several different ways it outputs JSON logs

orangain commented 1 week ago

@Twinki14

After digging deeper it looks like when debugging a project the debugger console is completely seperate than when running a project on it's own. The debugger console looks to be totally compatible with this plugin.

So, to recreate it, use a blank console project and debug it.

Thank you for the clarification, but I couldn't make the plugin work even when debugging a project.

I’m not sure if this is what you meant, but it seems that when I started debugging the project, the Rider shows two different but similar tabs “Console” and “Debug Output”. The former tab does not support the plugin while the latter tab supports the plugin. However I don't know how to output logs into the “Debug Output” tab.


Even such a situation, I think I could add a support for the Serilog.

It's also worth noting Serilog output is done in several different popular configurations.

https://github.com/serilog/serilog-formatting-compact is the most popular and has several different ways it outputs JSON logs

Thank you for the information. According to the documentation, it seems that there are four patterns of JSON formats as follows:

  1. JsonFormatter
  2. CompactJsonFormatter
  3. JsonFormatter(renderMessage: true)
  4. RenderedCompactJsonFormatter

The message template is an interesting idea, but some efforts are needed to support it. This is because it is not a simple substitutions but requires some calculations. Therefore, I would support the rendered version of the formatters, i.e. 3 and 4 for now, and I will leave 1 and 2 as future work.

orangain commented 5 days ago

@Twinki14 Now, new version 0.4.0 of the plugin that includes Serilog support has been released on the marketplace. Could you please try it? Thanks for the feedback!