Logging is like brushing your teeth every morning. The more you do it, the less hassle it seems. When your program crashes, logging gives you the insight to track and debug your code.
So, here are three best tips we find useful while logging:
𝑶𝒏𝒍𝒚 𝒍𝒐𝒈 𝒏𝒆𝒄𝒆𝒔𝒔𝒂𝒓𝒚 𝒂𝒏𝒅 𝒕𝒆𝒄𝒉𝒏𝒊𝒄𝒂𝒍 𝒔𝒐𝒖𝒓𝒄𝒆 𝒄𝒐𝒅𝒆 - we often find programmers overlogging causing significant time loss to filter when an error occurs.
𝑺𝒕𝒐𝒓𝒆 𝒕𝒉𝒆 𝒍𝒐𝒈 𝒊𝒏 𝒂 𝒔𝒊𝒏𝒈𝒍𝒆 𝒍𝒐𝒄𝒂𝒕𝒊𝒐𝒏 - when working on a project in a team, it is best to make the log visible to everyone involved for better efficiency and avoid miscommunication.
𝑷𝒓𝒐𝒑𝒆𝒓 𝒊𝒏𝒅𝒆𝒙𝒊𝒏𝒈 - Categorize and document with a universal language. It makes it easier to recheck the code over time.
There you go.
𝚂𝚝𝚊𝚛𝚝 𝚕𝚘𝚐𝚐𝚒𝚗𝚐 𝚊𝚗𝚍 𝚜𝚑𝚊𝚛𝚎 𝚢𝚘𝚞𝚛 𝚝𝚒𝚙𝚜 𝚋𝚎𝚕𝚘𝚠.