Open Alos opened 4 years ago
@Alos Just curious - are the logs containing the unformatted json, application logs? Or are they logs from skaffold (or something else)?
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>
@Alos Was the workaround given in chat (updating the logger configuration for Spring Boot) good enough or does this require further investigation?
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
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:
spring-cloud-gcp-starter-logging
artifact for stackdriver logging integrationlogback-json-appender.xml
which logs output to JSON so that it is consumable by Stackdriver:<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:
dev
uses a standard CONSOLE
appenderprod
uses the CONSOLE_JSON
appender for consumption by stackdriverThen, 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 :)
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.
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
Be aware that this only works for development and not for troubleshooting an app already running in the GKE cluster.
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.
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.
- 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