How should we keep our logs?

History of the Log

Advantages of logging

  • To see the IP source of outgoing requests to our system
  • Understanding the density of our system (User Interactions)
  • Detecting system behaviors (System start times, stop times)
  • Exploring performance statistics (request-response times)
  • Detecting threats and vulnerabilities (Constantly failing user verifications)

Log Levels

Fatal

Error

Warn

Info

  • A new record (for example, a user) has been created or its information has changed.
    The status of a particular record (for example, an order) changed from “shipped” to “completed”
    A regularly running Job is started.

Debug

Trace

Things to consider while keeping logs

Write meaningful log messages

Transaction failed
Record not found
User operation succeeds
Transaction failed: Phone 'abcabc' information is incorrect
Product with the id ’12121’ was not found
User 123456 successfully registered a cell phone.
Transaction failed: Phone information is incorrect {User: 123456, Phone: abcabc}
Product with the id ’12121’ was not found {Product: 12121}
User successfully registered a cell phone {User: 123456, Phone: 5*********}
ABC-E-USR-111 - Transaction failed: Phone information is incorrect {User: 123456, Phone: abcabc}
ABC-W-PRD-121 - Product with the id ’12121’ was not found {Product: 12121}
ABC-I-USR-123 - User successfully registered a cell phone {User: 123456, Phone: 5*********}

Write log messages in English

Do not create too many or too few logs

Do not save sensitive information in the logs!!!

  • credit card numbers
  • ID numbers
  • Passwords
  • Token
  • Personal names
  • Phone numbers
  • Session information

Consequent

Resources

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store