1
votes

I'm running a Java/Scala application in a container on GKE, and the logs are not populating in Stackdriver.

The GCP Console is showing that "Stackdriver Kubernetes Engine Monitoring" is enabled on the cluster, and "Legacy Stackdriver Logging" is disabled.

I've tried two types of logback files, one using ConsoleAppender and one using com.google.cloud.logging.logback.LoggingAppender, but neither works.

If I run a node.js app in GKE, then the console.log entries do show in Stackdriver.

To add some more detail that may help clarify, my main application container is a Node app that spawns a Java app. The Node app logs show in Stackdriver, but the Java app logs do not. I do set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account I'm using with permission to write to Datastore, Cloud Storage and PubSub. I didn't adding logging permissions to that account, because I figured there is another container or lower level process that writes the logs.

The last logback file I tried is:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
       <target>System.out</target>
       <encoder>
           <pattern>%X{akkaTimestamp} %-5level[%thread] %logger{0} - %msg%n</pattern>
       </encoder>
    </appender>

    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
       <appender-ref ref="STDOUT"/>
    </appender>

    <logger name="akka" level="INFO" />

    <root level="INFO">
       <appender-ref ref="STDOUT"/>
    </root>

</configuration>

What am I missing?

2
To which output stream the logs are being written to by node and java app ?Ankit Deshpande
Node is just doing console.log/warn/error, and on Java I'm using slf4j, with logback ConsoleAppender and target System.out, or com.google.cloud.logging.logback.LoggingAppender.jacob
@jacob had you tried following this answer ? stackoverflow.com/a/44168383/946789c69
@c69: I did see it, but I was unsure whether how pertinent it would be using the new beta "Stackdriver Kubernetes Engine Monitoring". I figure the legacy logging is different. Also, that person said he saw the logs in Stackdriver, but they were just not formatted correctly. I'm not seeing the logs at all.jacob
the only thing that i can suggest (which you probably already tried), but just try to find some ideas from default configuration docs cloud.google.com/logging/docs/agent/…c69

2 Answers

1
votes

I figured out the problem. When the node app spawns the Java process, it needs to configure the Java process to inherit the parent's stdio, like this:

const child = spawn(cmd, args, { stdio: 'inherit' ))
0
votes

Currently this is on Beta and is in a pre-release state and might change or have limited support.

But what you are looking is here: