{"id":496,"date":"2021-03-23T20:55:59","date_gmt":"2021-03-24T01:55:59","guid":{"rendered":"http:\/\/box5488.temp.domains\/~becomen3\/staging\/8495\/?p=496"},"modified":"2022-04-28T12:19:30","modified_gmt":"2022-04-28T17:19:30","slug":"why-does-writing-logs-is-more-important-than-what-you-think-in-software-development","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/why-does-writing-logs-is-more-important-than-what-you-think-in-software-development\/","title":{"rendered":"Key Reasons Why Logging is Important in Software Development"},"content":{"rendered":"\n<p>Chances are you are interested in leveling up your skills as a programmer and decided to start finding topics you are interested in learning something new such as the importance of logging in programming. Unfortunately, most programmers don\u2019t look for information about logging, especially entry-level programmers.<\/p>\n\n\n\n<p><strong>Here are the key reasons why logging is important in software development:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Helps Troubleshooting Bugs.<\/strong><\/li><li><strong>Improves Monitoring Projects in Production Environments<\/strong>.<\/li><li><strong>Facilitates Debugging.<\/strong><\/li><\/ol>\n\n\n\n<p>Let&#8217;s look at the reasons why logging is important in software development. However, before covering each, I share why typically experienced software engineers see the importance of logging as they advance in their careers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Only Experienced Software Engineers Know The Importance of Logging<\/h2>\n\n\n\n<p>The reality is adding logs is not the sexiest topic to talk about. In the end, logging, as you can infer, is about inserting a record in a document whatever you want to see.<\/p>\n\n\n\n<p>What would anyone research about logging?<\/p>\n\n\n\n<p>Trust me, you want to read about this before you finish the development of your first project. No matter how many years of experience you have, this article should be helpful for you. Oftentimes seasoned programmers understand the value of logging, and I could see that happening. It took me about three years of my professional career as a developer to start adding more logs to my projects.<\/p>\n\n\n\n<p>Just to make sure, don\u2019t go ahead and add a log for every single line of code in your app.<\/p>\n\n\n\n<p>Please don\u2019t.<\/p>\n\n\n\n<p>It is not about adding more logs and magically becoming a better programmer. Also, you will likely get a pull request (PR) full of comments about removing those logs.<\/p>\n\n\n\n<p>Logging is an essential aspect of software development. If you are a junior developer, you might say logging is not necessary as you can always debug each line of code and gain a complete understanding of what is going on in an app, such as checking the values of the parameters passed to a function.<\/p>\n\n\n\n<p>And to be honest that\u2019s a valid argument. <\/p>\n\n\n\n<p>Why bother adding more lines of code with logs if you have previously debugged and verified the code is working correctly?<\/p>\n\n\n\n<p>If you want to know why logging is important the hard way, go ahead and finish developing that project you\u2019ve been working on for months and publish it to a production environment. <\/p>\n\n\n\n<p>Whenever you get users bombarding your customer service, aka your email, about unexpected errors they found in your app, we can go for a cup of coffee and have time to talk about how you are going to quickly fix those unexpected bugs that even the QA team couldn\u2019t find during the testing phase, and that is if you have enough budget to pay someone to test your project.<\/p>\n\n\n\n<p>By the way, I meant a cup of hot chocolate as I\u2019m not a coffee guy\u2026<\/p>\n\n\n\n<p>Back to the point.<\/p>\n\n\n\n<p>If you don\u2019t want to make such a commitment to writing your whole app without writing logs, take this piece of advice: Add logs to your code. Skeptical about what I say? I would too. However, I have my arguments why writing logs is important for any programmer and must be part of any project.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/why-does-writing-logs-is-more-important-than-what-you-think-in-software-development\/#1_Helps_Troubleshooting_Bugs\" >Helps Troubleshooting Bugs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/why-does-writing-logs-is-more-important-than-what-you-think-in-software-development\/#2_Improves_Monitoring_Projects_in_Production_Environments\" >Improves Monitoring Projects in Production Environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/why-does-writing-logs-is-more-important-than-what-you-think-in-software-development\/#3_Facilitates_Debugging\" >Facilitates Debugging<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Helps_Troubleshooting_Bugs\"><\/span>1. Helps Troubleshooting Bugs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are a developer, you most likely have heard about deploying an application to different environments. Depending on the kind of project and company you work for, you will find different environments such as development, test, staging, and production. <\/p>\n\n\n\n<p>At the very least there has to be one environment where your application is deployed: production. No matter the environment an application is deployed to, you know there\u2019s a point where you don\u2019t have the ability to check step by step what is happening in an app, especially when bugs start happening and you need to take care of them as soon as possible.<\/p>\n\n\n\n<p>By adding logs, you can quickly determine, or at the very least get an idea of, why your application broke. Think about it, accessing log data allows you to attempt to replicate the same process a user was attempting to execute prior to the crashing of your project.<\/p>\n\n\n\n<p>This might sound like common sense. However, when starting your journey as a programmer, you usually do not have to worry about troubleshooting production issues, unless you are the creator of a project. However, other developers will appreciate it without knowing who wrote the logs at the beginning. Logging can make troubleshooting bugs a breeze.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Improves_Monitoring_Projects_in_Production_Environments\"><\/span>2. Improves Monitoring Projects in Production Environments<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Did you think logs could give you the benefit of monitoring your app? Some might say you are already monitoring your app by checking the data that is used. Oftentimes database records hold information such as the date when a record was created, updated, or deleted, and the user who performed each action. <\/p>\n\n\n\n<p>However, you might be leaving <a href=\"https:\/\/thenewstack.io\/logging-and-monitoring-why-you-need-both\/\" target=\"_blank\" rel=\"noreferrer noopener\">a lot of information on the table that can be monitored<\/a>. For example, you can add timestamps for every single log your application generates.<\/p>\n\n\n\n<p>Using this information will allow you, i.e., to determine the times when most of the users are actively using an app, to keep track of the time a background process is executed from the beginning until its completion, or to understand the vulnerabilities of your code after a hacker attacked your app. In the end, logs provide data. As you might have heard, data is <em>king<\/em>.<\/p>\n\n\n\n<p>If we stick with one of the previous examples, i.e, to determine the times when most of the users are actively using an app, this will allow an experienced developer to develop an infrastructure that will adjust at specific times to meet the demand of current connections and maintain your app stability and performance without crashing because it cannot keep up with the demand.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Facilitates_Debugging\"><\/span>3. Facilitates Debugging<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Certainly, software development is a process of constantly failing until you find the right solution to make an app work the way it is supposed to work. During the development stage, not all the time you are debugging every single line of code when executing processes after adding new lines of code. <\/p>\n\n\n\n<p>Sometimes you get unexpected data being passed to a function you initially didn\u2019t anticipate as part of your logic and all of the sudden your code breaks. Being able to quickly check the latest logs and get an idea of where the error is happening can save you time at the moment of adding the breakpoints and debugging to fix the bug.<\/p>\n\n\n\n<p>For example, it is common for javascript developers to use <code>console.log()<\/code> as it helps them to quickly identify bugs or any relevant information, even if there are better ways to debug the code such as <a href=\"https:\/\/developer.chrome.com\/docs\/devtools\/javascript\/#event-breakpoint\" target=\"_blank\" rel=\"noreferrer noopener\">pausing the code with breakpoints<\/a>. <\/p>\n\n\n\n<p>While logging might not be the best alternative for debugging, it facilitates debugging without adding any additional configuration to enable breakpoints, especially for programmers who don&#8217;t know yet how to configure their development environment to properly debug code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>All in all, I hope I made you realize the importance of logging in software development and see logging as an invaluable tool in your career. If I didn\u2019t change your mind, hopefully, you enjoyed reading this article. Logging is a simple concept, yet many don\u2019t use it because they don\u2019t see the value of using it. <\/p>\n\n\n\n<p>Now, you are ready to rock and <em>log<\/em>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chances are you are interested in leveling up your skills as a programmer and decided to start finding topics you are interested in learning something new such as the importance of logging in programming. Unfortunately, most programmers don\u2019t look for information about logging, especially entry-level programmers. Here are the key reasons why logging is important &#8230; <a title=\"Key Reasons Why Logging is Important in Software Development\" class=\"read-more\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/why-does-writing-logs-is-more-important-than-what-you-think-in-software-development\/\" aria-label=\"More on Key Reasons Why Logging is Important in Software Development\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":498,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general-info","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=496"}],"version-history":[{"count":4,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/496\/revisions"}],"predecessor-version":[{"id":2567,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/496\/revisions\/2567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/498"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}