Stackdriver - All logs are mapped as INFO

3/28/2019

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

-- Marcos Vidolin
kubernetes
logback
logging
spring-boot
stackdriver

1 Answer

4/29/2019

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?

-- Igor Peshansky
Source: StackOverflow