3

My question is can I create a java microservice able to read all the logs of the others microservices?

The exact path of the logs of my 2 deployed microservices is this:

/app/ZZZ/dyn/clients/log/zzz_clients.log
/app/ZZZ/dyn/checkout/log/zzz_checkout.log

Is it possible to create a new spring boot logging microService which will be deployed to this exact path:

/app/ZZZ/dyn/logging/

able to read to logs file of the others 2 microservices?

To be clear the folders:

/app/ZZZ/dyn/clients/

/app/ZZZ/dyn/checkout/

/app/ZZZ/dyn/logging/

are the one containing the following folders/file:

/app/ZZZ/dyn/nameOfMicroservice
|_ BOOT-INF
|_ ZZZ_nameOfMicroservice.jar
|_ META-INF
|_ org

where nameOfMicroservice is the: clients, checkout, logging

I know how to read a file contained inside the project folder but how can I read files external to my logging service jar is deployed?

thanks

user2298581
  • 532
  • 3
  • 11
  • 37
  • You mention that the folder /app/ZZZ/dyn/ is where the source code of the microservices resides (e.g. a git repo) but also that they are deployed there (e.g. .war/.jar file). Can you elaborate on the folder structure? – Omnibyte Jun 16 '22 at 08:23
  • that's exactly what the folder structure must look like in the servers. I don't have an application yet so neither git repo or local path folders to show, actually it's not important to me, what matters is that in the 2 servers that we have, the code will be as I described. – user2298581 Jun 17 '22 at 15:40
  • I have added additional details – user2298581 Jun 21 '22 at 15:08

1 Answers1

3

It is recommended implementing a centralized log storage and creating a separate logging service that receives log entries from different microservices and saves them in centralized storage.

Having centralized log storage simplifies logging, log retrieval, analytics, investigation, management and coordination of microservices log data.

Microservices logging best practices every team should know

What makes an effective microservices logging strategy?

Eskandar Abedini
  • 2,090
  • 2
  • 13
  • Could you elaborate more? I read your links and it seems is a best practice when there are a lot of microservices and moreover they are calling each other so it became difficult to figure out where problems occurs. In my case instead they are only 5 microservices and they are not calling each other so I think I don't need to centralize the logging. Am I correct? – user2298581 Jun 21 '22 at 09:41
  • You can give an identifier to each service that creates log and find its logs by that identifier – Eskandar Abedini Jun 21 '22 at 09:57
  • yeah but I already know that if I go to exact path of file /app/ZZZ/dyn/clients/log/zzz_clients.log I will find only the log of client microservice and the same for the other 4 path and relative microservices. Since they are not invoking each others I don't think it's troublesome to find the possible errors/exceptions in log right? – user2298581 Jun 21 '22 at 10:26
  • With logger microservice you can log to different files and so you have to all these file through logger [Log4j config - different logs to different files](https://stackoverflow.com/questions/23322602/log4j-config-different-logs-to-different-files) – Eskandar Abedini Jun 21 '22 at 10:37
  • My solution was an advice, you may find better solutions – Eskandar Abedini Jun 21 '22 at 10:39