I am having an containerised application with 1 container. In that container I have multiple pods.
For simplicity let’s take 3 pods. POD1 (with pod id as pd1), POD2 (pd2), POD3 (pd3)
In the log4j.yml file I have configured the app log files as:
fileName: "logs/app.log"
What it do is it generates app.log file in every instance of the pod in that container.
- POD1 -> in
logs
directory app.log is present - POD2 -> in
logs
directory app.log is present - POD3 -> in
logs
directory app.log is present
But I want the files to be like:
- POD1 -> in
logs
directory we should have app_pd1.log - POD2 -> in
logs
directory we should have app_pd2.log - POD3 -> in
logs
directory we should have app_pd3.log
What I tried:
As mentioned in Log4j Kubernetes Support
I tried fileName: "logs/app_${k8s:podId}.log"
But it didn’t worked, The file was made with static name as app_${k8s:podId}.log
in all the pods.