Search code examples
loggingmicroservices

Best practices for LOGGING in microservices architecture


What is the preferred way of handling logging in microservices architecture?

  1. Have an individual logging mechanism for each microservice
  2. Have one logging mechanism and have each microservice use it

Solution

  • Centralised logging is what you want to achieve at the end. I would look into direction of ELK Stack with Filebeat as a sidecar container.

    It might look like this:

    enter image description here

    1. A microservice logs everything into log files.
    2. Filebeat, run as a sidecar container for this microservice, has access to log files and ship them into Logstash.
    3. Logstash receives logs from Filebeat, transform and then send them to elasticsearch index.
    4. You can access your centralised logs with Kibana.