GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
320 stars 59 forks source link

As a user I want to have human readable Stackdriver logs in IntelliJ #2701

Open Alos opened 4 years ago

Alos commented 4 years ago

- Cloud Code for IntelliJ version: IntelliJ IDEA 2019.3.2 (Ultimate Edition) - OS: MacOS

What did you do? Used CC to develop an application on Kubernetes What did you expect to see? I expected to see human readable logs as they are streamed into IntelliJ What did you see instead? JSON formated strings show up instead.

The same happens if I stream logs using the Kubernetes Explorer

etanshaul commented 4 years ago

@Alos Just curious - are the logs containing the unformatted json, application logs? Or are they logs from skaffold (or something else)?

Alos commented 4 years ago

These are application logs exposed by Spring Cloud GCP and the following configuration for Stackdriver:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <include resource="org/springframework/cloud/gcp/logging/logback-json-appender.xml"/>

  <root level="INFO">
    <appender-ref ref="CONSOLE_JSON"/>
  </root>
</configuration>
jmah-cc commented 4 years ago

@Alos Was the workaround given in chat (updating the logger configuration for Spring Boot) good enough or does this require further investigation?

Alos commented 4 years ago

So far, I have not been able to configure logging to be Stackdriver friendly and human readable.

On Thu, Jun 11, 2020 at 9:37 AM Jay Mahendru notifications@github.com wrote:

@Alos https://github.com/Alos Was the workaround given in chat (updating the logger configuration for Spring Boot) good enough or does this require further investigation?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/cloud-code-intellij/issues/2701#issuecomment-642795908, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGG5AGEV5LLSV5OIIYLR3RWEB43ANCNFSM4KN6TZVA .

--

Sergio Felix

Software Engineer

etanshaul commented 4 years ago

Hey @Alos . Sorry for the slow turnaround on this, but I spent some time today playing around with this to see if I can get a working configuration. I was a bit skeptical that Cloud Code is the place to solve this. I made a few assumptions about your setup though:

<configuration>
  <include resource=
                         "org/springframework/cloud/gcp/logging/logback-json-appender.xml"/>
    <root level="INFO">
        <appender-ref ref="CONSOLE_JSON"/>
    </root>
<configuration>

Goal: Configure a logback appender for local dev that will output logs in a human readable way (e.g. not JSON).

Solution that worked for me: Use Spring Profiles to configure different logback appenders per environment.

In my logback-spring.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <springProfile name="dev">
        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>
                    %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n
                </pattern>
                <charset>utf8</charset>
            </encoder>
        </appender>
        <root level="DEBUG">
            <appender-ref ref="CONSOLE"/>
        </root>
    </springProfile>
    <springProfile name="prod">
        <include resource=
                         "org/springframework/cloud/gcp/logging/logback-json-appender.xml"/>
        <root level="INFO">
            <appender-ref ref="CONSOLE_JSON"/>
        </root>
    </springProfile>
</configuration>

Notice the two profiles:

Then, to activate the dev profile, for instance, I set an environment variable: spring.profiles.active=dev.

Result: Human readable application logs, not json formatted.

Let me know if this works for you and if not where I made incorrect assumptions. Looking forward to finding a solution that works :)

Alos commented 4 years ago

This is a good workaround for development workflows, where you can switch the profile. But does not solve the problem when we are inspecting troubleshooting services already running in other environments.

jmah-cc commented 3 years ago

Don't have plans to fix this as it's not a priority (and we have a partial workaround) at this time. Everyone: please upvote if you'd like to see this improvement and we'll re-visit

Alos commented 3 years ago

Be aware that this only works for development and not for troubleshooting an app already running in the GKE cluster.

etanshaul commented 3 years ago

Thanks @Alos on second thought I think we should keep this open. The robust solution would be to create a full featured log viewer like VSC has. I'll keep this open to track that part of the effort.

PierrickPuimeanChieze commented 2 years ago

I second this motion. The console log viewer is kind of slow to response for me, due to a bad internet connection. Having a full log viewer in standalone tool, like Cloud Code, would be a god gift.