Logging and monitoring
Logging microservices can help track errors and failures. Monitoring helps optimize microservices and can signal exceptional occurrences like security attacks.
In Chapter 6, Orchestrating Microservices With Celery and RabbitMQ, we already examined monitoring Celery with the Flower
package and RabbitMQ with its built-in features. Here, we focus more on signaling exceptions and reacting to such exceptions.
Depending on your situation and requirements, you can apply the following best practices for logging and monitoring:
- Apply integrated logging
- Implement log levels
- Alert anomalies
Next, we’ll look further into these best practices.
Apply integrated logging
You can build your own logging system, but applying the standard logging
module for Python is more efficient because it provides a comprehensive set of logging features.
For example, we can log the send mail error in send_email_task
to a text file instead of printing...