Logging

A log file records details of events occurring in a software application. The details may consist of micro-services, transactions, service actions, or anything helpful in debugging the flow of an event in the system. Logging is crucial to monitor the application’s flow.

Need for logging

Logging is essential in understanding the flow of an event in a distributed system. It seems like a tedious task, but upon facing a failure or a security breach, logging helps pinpoint when and how the system failed or was compromised. It can also aid in finding out the root cause of the failure or breach. It decreases the mean time to repairMean time to repair (MTTR) is a basic measure of the maintainability of repairable items. It represents the average time required to repair a failed component or device. (Definition taken from Wikipedia) of a system.

A question can be raised: why don’t we simply print out our statements to understand the application flow? It’s possible, but not ideal. Simple print statements have no way of tracking the severity of the message. The output of print functions usually goes to the terminal, while our need could be to persist such data on a local or remote store. Moreover, we can have millions of print statements, so it’s better to structure and store them properly. Concurrent activity by a service running on many nodes might need causality information to properly stitch together a correct flow of events. (Dealing with causality needs care in a distributed system.) We use a logging service to appropriately manage the diagnostic (and exploratory) data of our distributed software.

Logging allows understanding our code, locating unforeseen errors, fixing the identified errors, and visualizing the application’s performance. This way, we are not blind in production, and we know how things are running in the system.

Log analysis helps us with the following scenarios:

  • To troubleshoot applications, nodes, or network issues
  • To adhere to internal security policies, external regulations, and compliance.
  • To recognize and respond to data breaches and other security problems
  • To comprehend users’ actions for input to a recommender system.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy