Quarkus - configure logging with kubernetes cluster Quarkus - configure logging with kubernetes cluster kubernetes kubernetes

Quarkus - configure logging with kubernetes cluster


If you are using Kubernetes resource yaml to deploy your app, use the snippet below to push your custom ConfigMap as environment variables to your applicaton (https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#configure-all-key-value-pairs-in-a-configmap-as-container-environment-variables):

spec:      containers:        - name:           image:          envFrom:            - configMapRef:                name: kube-cm-config-map

Use a different ConfigMap for each environment but with the same name. If your environments (dev/qa/etc) are Kubernetes namespaces, then it is very easy to setup. Just duplicate the ConfigMap in each namespace, and change the log level value in each namespace.

Also, change the naming convention for your ConfigMap properties from log.file.level to LOG_FILE_LEVELSee https://quarkus.io/guides/config-reference#environment_variables


Ok solved by editing the cm in the following way:

data:QUARKUS_LOG_FILE_ENABLE: "true"QUARKUS_LOG_FILE_FORMAT: '%d{HH:mm:ss} %-5p [%c{2.}] (%t) %s%e%n'QUARKUS_LOG_FILE_LEVEL: ERRORQUARKUS_LOG_FILE_PATH: /tmp/kube-cm.log

Then I set application.properties on quarkus with:

quarkus.kubernetes.env.configmaps=kube-cm-config-map


There are 2 ways to use a ConfigMap in Quarkus to read runtime configuration.

The first is to let Quarkus query the API server using the quarkus-kubernetes-config extension which is described here.

The second way to configure the Kubernetes Deployment to turn ConfigMap values into environment variables for the Pod. This can be done with the quarkus-kubernetes extension which is described here.

So you would add the proper quarkus logging configuration (i.e a key value pair) in the ConfigMap and then use one of the above methods to use that at runtime