Is there a way to use Kubernetes Container environment variables in the Log4Net.config?

5/17/2019

I am trying to find out if I can use a container environment variable inside the Log4Net.config to separate our logs environment, for easier reading on Kibana.

My idea was to set a variable in the container that appends into the ApplicationName value of our RabbitMqAppender.

I probably could use a configMap for the Log4Net.config, but I don't think it would be viable for the number of applications we have running.

-- GabrielJohansson
kubernetes
log4net

1 Answer

5/17/2019

A typical pattern here is to use a log processor sidecar. Some of the ones you can use are:

For any logger about you can use a ConfigMap for different types of applications.

Another pattern is to use any of the above tools deployed as DaemonSet where each daemon in the Kubernetes picks everything up from a mountPath and forwards it to an ElasticSearch instance. For example, forwards everything under /var/log/containers/*.log

In all examples, it's assumed that your containers are logging to stdout/stderr.

-- Rico
Source: StackOverflow