Configure Kubernetes logs in different path with Spring Logback
You need to:
- move that file onto an emptyDir volume (or hostPath I guess but use emptyDir) and then
- run fluentd/bit as a sidecar which reads from that volume and
- forwards to the rest of your fluentd setup.
- In the dockerfile for the spring boot app create a directory where logs will be written
- In the logback xml file have a FileAppender which will write logs in that directory path
- Have the logback xml file as part of the jar file in
resources
folder. - Add Fluentd sidecar into the pod spec of the spring boot app
- Configure Fluentd sidecar to tail logs from the log file written in that directory path.