Search code examples
spring-bootloggingkuberneteslogbackstackdriver

Stackdriver - All logs are mapped as INFO


All my logs ERROR/WARNIN are mapped as INFO at Stackdriver. I'm using logback and Im running my application in a Kubernetes cluster.

How can I setup my logback to Stackdriver?

Tks


Solution

  • The Stackdriver logging agent configuration for Kubernetes defaults to INFO for any logs written to the container's stdout and ERROR for logs written to stderr. If you want finer-grained control over severity, you can configure Spring to log as single-line JSON (e.g., via JsonLayout1) and let the logging agent pick up the severity from the JSON object (see https://cloud.google.com/logging/docs/agent/configuration#process-payload).

    1By default, JsonLayout will use "level" for the log level, while the Stackdriver logging agent recognizes "severity", so you may have to override addCustomDataToJsonMap.

    See also GKE & Stackdriver: Java logback logging format?