0

Considering a K8s cluster has 3 pods, each has a docker container of same SpringBoot app providing web services, with LogBack as logging solution.

Log path for each Spring Boot app is the same, and each application will do the same file logging, defined in application.properties. I wonder if without any volume configuration, is it going to cause locking situation so that each Spring Boot app will try to write to the same file at same time?

If above speculation is true, what is the best practice? Below is what I can think of

  1. Create different volume for each pod so logging file write to different physical location. I think it is an overkill for logging

  2. Generate unique file name suffix so app log file name for each application is different. Simply can be just cut off of pod name. However this solution requires to pass dynamic parameters to the pod -> container -> application

Dreamer
  • 7,333
  • 24
  • 99
  • 179
  • 1
    Its good to use ELK stack . I think logstash will work . https://stackoverflow.com/questions/57399354/send-spring-boot-logs-directly-to-logstash-with-no-file – sjy Aug 01 '22 at 23:52
  • You don't have to pass anything to your application explicitly to get the name of the pod it's running in. Just use the existing environment variable. https://stackoverflow.com/a/51594557/4571544 – dekkard Aug 02 '22 at 06:30
  • 1
    If you have to log to a file I would go for option 2), i.e using some kind of suffix. However, I would recommend to take a look at centralized log aggregation tools like Splunk or Graylog and e.g have a log appender sending the logs directly to that tool without logging to a file. More options can be found here https://landscape.cncf.io/card-mode?category=logging&grouping=category – Hans-Christian Aug 02 '22 at 21:05

0 Answers0