This content originally appeared on DEV Community and was authored by Sankararaman K
Logging is the process of creating a trail of logs of a particular process or logic flow.
What is a log?
A log is a record of an event.
What types of events should be logged?
Events that should be logged depends on the use-case. Some use-cases where events should be logged are
- Failure logging
- Log a trail of events that can lead to failure
- Make sure these events don't create noice during successful execution
- For example:
[Thu Mar 13 19:04:13 2014] [error] [client 10.1.10.50] File does not exist: /var/www/favicon.ico
- Analytics logging
- Log API endpoints to identify which APIs are frequently used
- Log execution duration to track API response times
- For example:
10.1.10.50 [Thu Mar 13 19:04:13 2014] 808840 “GET /inventory/item?itemId=234” 500”
Other Considerations
- Logs should readable
- Logs should not be noisy
- Logs should be searchable and filterable
- This can be done by assign a unique ID to every request and it can be used to filter all logs related to that ID
What other types of events do you log? What other parameters do you consider while defining a log? Feel free to add them in the comments!
This content originally appeared on DEV Community and was authored by Sankararaman K
Sankararaman K | Sciencx (2024-11-08T06:37:17+00:00) Fundamentals of Logging. Retrieved from https://www.scien.cx/2024/11/08/fundamentals-of-logging/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.