Logging in JavaScript Best Practices

**The Importance of Progress Logging**

Progress logging is all about answering a simple yet crucial question: "Are you okay? Are you still working?" It's a vital tool for developers and users alike, as it helps to alleviate anxiety by providing a clear picture of an application's behavior. By logging percentage of progress, errors that have happened, and what's going on, we can better understand the application's performance and identify potential issues.

**The Benefits of Progress Logging**

Progress logging is often overlooked, but it's essential for ensuring that applications are functioning correctly. By providing a clear picture of an application's behavior, progress logs can help to detect errors and issues earlier on. This can be particularly useful when working with large datasets or complex systems. For example, when clicking on a button on a website, we want to know if the application is going to work quickly or if it's going to take longer. If the application takes too long to respond, we're likely to refresh the page or try again.

**Audit Logging**

Another crucial aspect of progress logging is audit logging. This involves verifying that the behavior of the application is correct and that data is being stored accurately. In banking, for example, it's essential to verify that transactions are being recorded correctly and that account balances are up-to-date. Audit logs help to ensure that this information is accurate and reliable, reducing the risk of errors or discrepancies.

**The Importance of Context**

When writing logs, it's essential to consider the context in which they will be read. Who will be reading the data? Will they be able to understand what's going on without additional information? This is particularly important when working with sensitive information such as personal data or passwords. In these cases, it's essential to remove any identifiable information and ensure that the logs are understandable by non-technical users.

**The Golden Rules of Logging**

When writing logs, there are three key things to consider:

1. **Answer the question**: What question are you trying to answer with your logs? Are you trying to answer how an application is functioning correctly or if it's experiencing errors?

2. **Make it understandable**: Ensure that your logs are understandable by non-technical users and that they can be easily parsed.

3. **Remove personal data**: Remove any identifiable information such as personal data, passwords, or usernames from your logs.

**A Personal Example**

I remember one time when I kept a log of my sailing adventures in a book with pen. It was a simple yet effective way to track my progress and identify potential issues. One day, I picked up the boat and ran a test, but it took longer than expected for the build pump to function correctly. Later that day, an engineer came in and fixed the issue, but not before it had run several tests. By reviewing my logs, I was able to see what had happened and identify potential issues.

**The Power of Visualizing Logs**

Progress logs can be incredibly powerful when used effectively. By displaying them in a graph or chart, we can easily visualize trends and patterns. In the case of the build pump on the sailboat, I noticed that even after the engineer fixed the issue, subsequent test runs were still taking longer than expected. This was due to an overhead in the pump's spinning up time, which could be optimized by adjusting the pump's settings.

**The Value of Similarity in Logs**

Another important aspect of progress logging is similarity in logs. When multiple tests run are similar in output, it can indicate a potential issue or area for improvement. In this case, I noticed that even after the engineer fixed the issue, subsequent test runs were still producing similar results. This suggested that there was an underlying problem with the pump's behavior, which needed to be addressed.

**Conclusion**

Progress logging is a crucial aspect of application development and maintenance. By answering the question "Are you okay? Are you still working?", we can better understand our applications' behavior and identify potential issues earlier on. By considering context, making logs understandable, removing personal data, and following the golden rules of logging, we can ensure that our logs are effective and informative.

"WEBVTTKind: captionsLanguage: enso i'm gonna be talking about logging obviously um so but first a couple of apologies um the first apology is to the guy with the camera i'm gonna be moving around a lot um and the second apology is to you guys because i was expecting to be i was expecting to be doing this talk preparing the talk over the last bank holiday weekend you know finishing it up i ended up going sailing instead on the norfolk broads so i spent the whole time in a boat in the ring which you'll hear about in a second so i'm going to switch the first slide so the camera can sync up and this is kind of an interactive first session put your hands up if you talk about logging in your code style guides at work okay inverse put your hand up if you do sorry if you don't if you don't okay fine yeah so people don't tend to talk about logging very much which is weird considering it's like one of the oldest things that we do in software back when we logged to pieces of paper before i was born probably so we don't talk about logging in our style guides has anybody ever been taught logging best practices okay put your hand up if you have not been taught logging best practices no put your hand up if you've ever thought about logging best practices okay cool this is awesome a few people has anybody ever tested their logs put your hand up tested your logs nice tested javascript blogs okay so my name's joseph roof i am at jreav00 on twitter at joe on the slack group for this for this kind of community um if you want my details you can go to joe.contactme.io and the slides should you want to find them are at that link take a picture now if you want this slide will also be at the end so log books this is kind of coming into the sailing thing log books are really really cool because we've been doing this for ages right people on boats have been sitting down every hour when they're out at sea they say this is our heading when i'm writing this log this is what the wind is like you know standard stuff about boats and that kind of gets locked in a box which hopefully should the ship sink somebody else can come along and find it the floating box that's kind of somewhere on the sea they know what the ship is they know where they were when it all went wrong they know what the conditions were and potentially you know they can actually diagnose the exact reason this ship sunk in the middle of the night somewhere you know and they also know what's on it so is it worth going and looking for it and finding all the hidden treasure on at the bottom of the sea um but also is it worth sending out a rescue party was it just one person and you know this log book is being found 20 years later so when i went sailing the guys at the boatyard where i rented the boat they know me i've been there for a while they said since you've had last had this boat these are the things we've changed the bilge washers so the bilge is the bit of water kind of underneath the floor so there's a little kind of it's called the bilge a little bit of air that water can go into and if that gets too full water starts coming up through the floor and you start to sink basically um but generally boats are always slowly sinking and we have little pumps that take the water out of the boat they also change the countertops lovely we've got these nice granite looking countertops now which is brilliant they changed the water heater which is cool because now we get hot water and they changed the engine they also changed a bunch of batteries and stuff so they said to me seeing as we know you and seeing as all this stuff's new when you're the first hire of the year which at the time i thought was great now i know it's not um seeing as you're the first time of the year the first one to use all of this cool new stuff could you keep a log of the bilge pump how long do you hold the build pump for so the whole holiday went really really well i got back on monday evening except the countertop fell off and broke four bottles of beer the beer from the bottles then went into the pilg the water heater used up all of our water when it shouldn't have and put all the excess water into the bilge the engine died which was fun in the middle of nowhere and then it rained on stop and does anyone know where the rain goes in a boat say it out loud into the bilge exactly into the bilge so this was me in the rain with a cup of coffee it's kind of okay um so now let's talk about javascript logging because that's why we're all here right or that's why i'm here at least javascript logging is cool because it's kind of not done very much but there's loads of kind of prior art so us javascript developers and lots of developers have a really really nasty habit we tend to reinvent the wheel over and over again has anyone heard of web workers right that's threading accidentally reinvented badly or worklets which is reinventing the um the actor model but without having the name so you can't google what it is um but kind of the time when i had the red pill you know i you know matrix style i started to actually think about logging it was when i was talking to a friend of mine julian who's at the back on his phone um so he's doing a lot of work in analytics and logging software um a lot of android stuff and non-javascript stuff but i went over and i had a chat with them and we talked about logging for three four hours um and this is the first time i've actually talked to someone about logging because surely like console.log it worked you know console.log debug hello um so i talked to him about this and it wasn't boring which was the first thing that surprised me talking about logging wasn't boring and then i went to work the next morning and saw this log there's this statement this bit of code and i was like what get blamed launch missiles kill them you know who on earth did this which obviously if any of you have ever done a git blame on a piece of code that looks rubbish don't because it's always you that wrote it so i was looking at this code and i was thinking this is bad this console.log statement is bad and i have no idea why it's bad right just no idea i just i know because i've had this long conversation but i don't know why it's bad right so i started looking for other things um console.log error error.message right why is that bad come to it console.error fazzom that is has anyone here ever worked with the hungarian yeah a hungarian programmer yeah put that into google translate the polite translation is oh and then console.log finished at date.now does anyone know what date.now outputs a bunch of numbers right not human readable so i was like these are all bad all of these hundreds of log statements in this code base that i'm responsible for are bad you know i can't look at the the logs and know what's going on know if the system's even okay let alone if the users are okay and these are systems running you know that a couple of layers down people are trading half a million pounds on a day or are deciding whether or not to run trains like these are dangerous systems if things go wrong luckily this isn't directly it but this is kind of a couple of layers away so i kind of thought about it for a while and i thought there are four dimensions four things that you can kind of focus on you can think about specifically that make a log good or bad so you've got context what's going on in the app what's the data what's the time what's yeah we'll come back what's the purpose is it for debugging and i'm going to i think i'm going to delete it before i commit it is it for um auditing you know we did have this many users log in and the product owner knows it and they went to these sites and they did this and this and this is it important is someone about to die is someone about to lose half a million pounds or was there a garbage collection event and the format is it human readable is it greppable you know grep unix grep yeah can i just grab my logs and see every time this user logged in or can i grab my logs and see every time there was an error every time something went wrong the purpose so we might be doing analytics which is a kind of logging i promise you you can ask me about it later the purpose is it for debugging or is it for analytics improving the user experience did someone die did someone just log in was there a garbage collection event you know is it scannable is it possible which is really really important if you're using something like stash has anyone heard of logs it's a tool you know elastic search guys for dealing with logs so that's context purpose importance and format they're all things that are important when we're writing logs so none of this stuff is new you can see examples of all this stuff in log4j which is a java logging library which is kind of industry standard for java stuff the syslog standard which is kind of has bits of bits of stuff just look it up on online um count.lee which there are some stickers around somewhere they i had a chat with the ceo and he sent me some stickers which they open source rocks which is cool so they're over there somewhere and that's just a tool for you know logging events logging arrows logging different things to a remote location from the client or from other languages logs dash and good old console. you know we've got console.log error warn info different kind of levels importances and then we've got things like timing and profiler loads of really cool stuff just open dev tools type console. and look at the intellisense really cool stuff so this is an example of a bad format of logs has anybody seen this in their log files raise your hands if you've seen something like this in your log files yeah someone's just logged out some array and you've just got object object object object takes up hundreds of lines of logs and yeah you know you kind of lose the context so this is this breaks any context you've got a good format is showing the user that logged in wrapping things in square brackets makes things really possible they're surprising i mean i'm going to say regular expressions right but if you need to do something quickly regular expressions are really handy or grepping for things using regular expressions logging errors instead of doing console.log blah error.message just log the actual error not appended to a string and it'll actually display the whole stack trace which is lovely and this is this is an example of showing context this is ip addresses so we're showing context of where this stuff happened from which is important when we come to this kind of thing right user logged in use logged in use logged in error got data pretty rubbish because we don't know what's going on this means a lot different right so we've got the same user logged in five times within one second either we've got a bug or we've got a bot right both of these things are important and if you've got your ip address you can start looking at the ip address is it a real user is it some kind of bot scraper we've had that a lot stealing lots of valuable data they pay for one user and they're they've got their bots going off and downloading huge amounts of data so it all depends on the goal the logs that you actually use the logging statements the logging context the data i can't just come up here and say log the ip addresses or log the users or whatever you know i can't say log this log that because it depends so much on your individual context on your application on your users and on what you're expected to provide for your customers so it depends on the goal has anyone read the goal by eli goldwrap no one okay first thing you do when you get home go on amazon order the goal it's about kanban management or something but it's really really good at helping you understand where in an organization developers you know developers fit and how they can help the wider organization so there's this thing i made up this morning called the logging type table and basically this is talking about the different types of logging the different reasons you might use a log statement so we've got some things it's a bit small different different types of logging so there's there's something called tracing has anyone heard the term tracing before yeah okay so tracing is often used for debugging it's kind of logging you know function invocations or individual variables and just for really when when there's some bug that you're looking at so the question it answers is what happened you know how did we get here what happened what did the user do to get to this point or what data came in to get to this point and we usually log the state changes and function invocations and it's targeted at developers so there's anyone heard of event logging fairly common term event logging it's analytics it's understanding what's going on inside the app is that a user doing specific things or is it the application doing specific things so what's happening action actions and exceptions and it's useful for administrators um product owners and kind of us as developers we know which bits of code to specifically improve progress logging which is something that probably we don't think much about um this can actually feed back to users of um applications has anyone ever used uh dd the unix tool dd raise your hands no one's used dd what has anyone ever moved an image file not a img onto an sd card for like a raspberry pi or something no wow okay so dd is an example of bad logging because you press dd and it starts copying this three gigabyte file onto an sd card and it just sorry the command dd yeah the unix utility yeah um so dd you type dd this big file onto this sd card which i haven't used in three years maybe it'll work and it just sits there staring at you blank right no logging no explanation of what's going on it just kind of sits there and then come back in half an hour and hopefully it's worked right so that's that's kind of induces a lot of anxiety in its users so the question so progress logging is all about answering the question are you okay are you still working have you crashed is there anything i can do to help basically so we kind of log percentage of progress what errors have happened what's going on targeted at users because this can bubble up to some application if i click a button in on some website and it starts churning away chugging away and it doesn't load in five seconds i'm gonna hit refresh right but if some pop-up comes up and says this is gonna take a while we're loading the page for you we're aggregating the data then you're more likely to kind of wait for it right so then there's audit which is kind of something that we really really don't think think about much which is kind of verifying that the behavior of the application is correct you know did when my bank sent money do they log saying we transferred this much money from this account to this account and this accounts you know amount of money decreased by the same amount and this account increased right this is kind of double entry bookkeeping so what accountants do is they just look at the data from different angles and they just make sure everything lines up and this is something that your compliance departments might need the government might want like gdpr type stuff and the rest of the business might want because they want to know how many users of work you know are using the tool um is the number of subscribers going down every month which is obviously a bad thing um yeah so that's the the logging type table so purple slides again we're nearly at the end don't worry i'm just going to wrap up the sailing stuff so oh no i'm not i'm going to do this instead so the logging golden rules the three things to consider when you're writing logs and then i'm going to wrap up the same stuff remember the reader so this is who's reading the data is it going to be parsed are they going to be unable to understand what's going on do they know the context no personal data no passwords i've seen that a lot no passwords no usernames no email addresses um depends on the context obviously and then answer the question think about what question are you trying to answer with these locks are you trying to answer how do we get here are you trying to answer are you functioning correctly are you trying to answer um answer this this random question that the marketing guy said hey i'd really love to know how many users log in every three seconds or every three days right if there's some specific thing that's that's kind of the question and you need to make sure that that's understandable in the logs itself okay sailing now we're on sailing so this was my log that i kept in a book with paper and pen i mean hardcore stuff right so there are a few things that we can we can kind of keep take note of that we can actually learn so this is event logging this is me saying i did this and it happened for this long so this is when i picked the boat up yeah you can see the oh well the day i picked the boat up and the first time i ran the test and it ran for kind of three seconds then you can see something went wrong because suddenly my build pump the thing that's supposed to stop me from sinking takes 12 seconds to do its job and then some engineer came in the middle of the day you'll see by the rest of the logs that it's kind of a weird time in the middle of the day he came and he fixed something and then ran it for 10 seconds so this is an abnormal log right so something different happened and then you can see something went wrong it's not immediately obvious but if you're kind of displaying this in a graph it's quite helpful that i actually missed the morning here i missed the morning on the second of the fourth and that's because uh we had more issues with our water heater and suddenly worrying about actually being able to drink water was more important than uh than measuring how long our build pump ran for so that's something else went wrong and then that's when i ran that just before i dropped the boat off so another interesting thing is after the the tests after the guy fixed it these tests are all very similar even though the amount of rain changes right so the actual test runs change um so don't change much sorry which means there's probably a lot of overhead in in the pump from spinning up right but there's a lot of overhead and you can tell because the values are similar not because they're different so similarities in logs is still really really handy okay that's it you can drink more beer eat more pizza coolso i'm gonna be talking about logging obviously um so but first a couple of apologies um the first apology is to the guy with the camera i'm gonna be moving around a lot um and the second apology is to you guys because i was expecting to be i was expecting to be doing this talk preparing the talk over the last bank holiday weekend you know finishing it up i ended up going sailing instead on the norfolk broads so i spent the whole time in a boat in the ring which you'll hear about in a second so i'm going to switch the first slide so the camera can sync up and this is kind of an interactive first session put your hands up if you talk about logging in your code style guides at work okay inverse put your hand up if you do sorry if you don't if you don't okay fine yeah so people don't tend to talk about logging very much which is weird considering it's like one of the oldest things that we do in software back when we logged to pieces of paper before i was born probably so we don't talk about logging in our style guides has anybody ever been taught logging best practices okay put your hand up if you have not been taught logging best practices no put your hand up if you've ever thought about logging best practices okay cool this is awesome a few people has anybody ever tested their logs put your hand up tested your logs nice tested javascript blogs okay so my name's joseph roof i am at jreav00 on twitter at joe on the slack group for this for this kind of community um if you want my details you can go to joe.contactme.io and the slides should you want to find them are at that link take a picture now if you want this slide will also be at the end so log books this is kind of coming into the sailing thing log books are really really cool because we've been doing this for ages right people on boats have been sitting down every hour when they're out at sea they say this is our heading when i'm writing this log this is what the wind is like you know standard stuff about boats and that kind of gets locked in a box which hopefully should the ship sink somebody else can come along and find it the floating box that's kind of somewhere on the sea they know what the ship is they know where they were when it all went wrong they know what the conditions were and potentially you know they can actually diagnose the exact reason this ship sunk in the middle of the night somewhere you know and they also know what's on it so is it worth going and looking for it and finding all the hidden treasure on at the bottom of the sea um but also is it worth sending out a rescue party was it just one person and you know this log book is being found 20 years later so when i went sailing the guys at the boatyard where i rented the boat they know me i've been there for a while they said since you've had last had this boat these are the things we've changed the bilge washers so the bilge is the bit of water kind of underneath the floor so there's a little kind of it's called the bilge a little bit of air that water can go into and if that gets too full water starts coming up through the floor and you start to sink basically um but generally boats are always slowly sinking and we have little pumps that take the water out of the boat they also change the countertops lovely we've got these nice granite looking countertops now which is brilliant they changed the water heater which is cool because now we get hot water and they changed the engine they also changed a bunch of batteries and stuff so they said to me seeing as we know you and seeing as all this stuff's new when you're the first hire of the year which at the time i thought was great now i know it's not um seeing as you're the first time of the year the first one to use all of this cool new stuff could you keep a log of the bilge pump how long do you hold the build pump for so the whole holiday went really really well i got back on monday evening except the countertop fell off and broke four bottles of beer the beer from the bottles then went into the pilg the water heater used up all of our water when it shouldn't have and put all the excess water into the bilge the engine died which was fun in the middle of nowhere and then it rained on stop and does anyone know where the rain goes in a boat say it out loud into the bilge exactly into the bilge so this was me in the rain with a cup of coffee it's kind of okay um so now let's talk about javascript logging because that's why we're all here right or that's why i'm here at least javascript logging is cool because it's kind of not done very much but there's loads of kind of prior art so us javascript developers and lots of developers have a really really nasty habit we tend to reinvent the wheel over and over again has anyone heard of web workers right that's threading accidentally reinvented badly or worklets which is reinventing the um the actor model but without having the name so you can't google what it is um but kind of the time when i had the red pill you know i you know matrix style i started to actually think about logging it was when i was talking to a friend of mine julian who's at the back on his phone um so he's doing a lot of work in analytics and logging software um a lot of android stuff and non-javascript stuff but i went over and i had a chat with them and we talked about logging for three four hours um and this is the first time i've actually talked to someone about logging because surely like console.log it worked you know console.log debug hello um so i talked to him about this and it wasn't boring which was the first thing that surprised me talking about logging wasn't boring and then i went to work the next morning and saw this log there's this statement this bit of code and i was like what get blamed launch missiles kill them you know who on earth did this which obviously if any of you have ever done a git blame on a piece of code that looks rubbish don't because it's always you that wrote it so i was looking at this code and i was thinking this is bad this console.log statement is bad and i have no idea why it's bad right just no idea i just i know because i've had this long conversation but i don't know why it's bad right so i started looking for other things um console.log error error.message right why is that bad come to it console.error fazzom that is has anyone here ever worked with the hungarian yeah a hungarian programmer yeah put that into google translate the polite translation is oh and then console.log finished at date.now does anyone know what date.now outputs a bunch of numbers right not human readable so i was like these are all bad all of these hundreds of log statements in this code base that i'm responsible for are bad you know i can't look at the the logs and know what's going on know if the system's even okay let alone if the users are okay and these are systems running you know that a couple of layers down people are trading half a million pounds on a day or are deciding whether or not to run trains like these are dangerous systems if things go wrong luckily this isn't directly it but this is kind of a couple of layers away so i kind of thought about it for a while and i thought there are four dimensions four things that you can kind of focus on you can think about specifically that make a log good or bad so you've got context what's going on in the app what's the data what's the time what's yeah we'll come back what's the purpose is it for debugging and i'm going to i think i'm going to delete it before i commit it is it for um auditing you know we did have this many users log in and the product owner knows it and they went to these sites and they did this and this and this is it important is someone about to die is someone about to lose half a million pounds or was there a garbage collection event and the format is it human readable is it greppable you know grep unix grep yeah can i just grab my logs and see every time this user logged in or can i grab my logs and see every time there was an error every time something went wrong the purpose so we might be doing analytics which is a kind of logging i promise you you can ask me about it later the purpose is it for debugging or is it for analytics improving the user experience did someone die did someone just log in was there a garbage collection event you know is it scannable is it possible which is really really important if you're using something like stash has anyone heard of logs it's a tool you know elastic search guys for dealing with logs so that's context purpose importance and format they're all things that are important when we're writing logs so none of this stuff is new you can see examples of all this stuff in log4j which is a java logging library which is kind of industry standard for java stuff the syslog standard which is kind of has bits of bits of stuff just look it up on online um count.lee which there are some stickers around somewhere they i had a chat with the ceo and he sent me some stickers which they open source rocks which is cool so they're over there somewhere and that's just a tool for you know logging events logging arrows logging different things to a remote location from the client or from other languages logs dash and good old console. you know we've got console.log error warn info different kind of levels importances and then we've got things like timing and profiler loads of really cool stuff just open dev tools type console. and look at the intellisense really cool stuff so this is an example of a bad format of logs has anybody seen this in their log files raise your hands if you've seen something like this in your log files yeah someone's just logged out some array and you've just got object object object object takes up hundreds of lines of logs and yeah you know you kind of lose the context so this is this breaks any context you've got a good format is showing the user that logged in wrapping things in square brackets makes things really possible they're surprising i mean i'm going to say regular expressions right but if you need to do something quickly regular expressions are really handy or grepping for things using regular expressions logging errors instead of doing console.log blah error.message just log the actual error not appended to a string and it'll actually display the whole stack trace which is lovely and this is this is an example of showing context this is ip addresses so we're showing context of where this stuff happened from which is important when we come to this kind of thing right user logged in use logged in use logged in error got data pretty rubbish because we don't know what's going on this means a lot different right so we've got the same user logged in five times within one second either we've got a bug or we've got a bot right both of these things are important and if you've got your ip address you can start looking at the ip address is it a real user is it some kind of bot scraper we've had that a lot stealing lots of valuable data they pay for one user and they're they've got their bots going off and downloading huge amounts of data so it all depends on the goal the logs that you actually use the logging statements the logging context the data i can't just come up here and say log the ip addresses or log the users or whatever you know i can't say log this log that because it depends so much on your individual context on your application on your users and on what you're expected to provide for your customers so it depends on the goal has anyone read the goal by eli goldwrap no one okay first thing you do when you get home go on amazon order the goal it's about kanban management or something but it's really really good at helping you understand where in an organization developers you know developers fit and how they can help the wider organization so there's this thing i made up this morning called the logging type table and basically this is talking about the different types of logging the different reasons you might use a log statement so we've got some things it's a bit small different different types of logging so there's there's something called tracing has anyone heard the term tracing before yeah okay so tracing is often used for debugging it's kind of logging you know function invocations or individual variables and just for really when when there's some bug that you're looking at so the question it answers is what happened you know how did we get here what happened what did the user do to get to this point or what data came in to get to this point and we usually log the state changes and function invocations and it's targeted at developers so there's anyone heard of event logging fairly common term event logging it's analytics it's understanding what's going on inside the app is that a user doing specific things or is it the application doing specific things so what's happening action actions and exceptions and it's useful for administrators um product owners and kind of us as developers we know which bits of code to specifically improve progress logging which is something that probably we don't think much about um this can actually feed back to users of um applications has anyone ever used uh dd the unix tool dd raise your hands no one's used dd what has anyone ever moved an image file not a img onto an sd card for like a raspberry pi or something no wow okay so dd is an example of bad logging because you press dd and it starts copying this three gigabyte file onto an sd card and it just sorry the command dd yeah the unix utility yeah um so dd you type dd this big file onto this sd card which i haven't used in three years maybe it'll work and it just sits there staring at you blank right no logging no explanation of what's going on it just kind of sits there and then come back in half an hour and hopefully it's worked right so that's that's kind of induces a lot of anxiety in its users so the question so progress logging is all about answering the question are you okay are you still working have you crashed is there anything i can do to help basically so we kind of log percentage of progress what errors have happened what's going on targeted at users because this can bubble up to some application if i click a button in on some website and it starts churning away chugging away and it doesn't load in five seconds i'm gonna hit refresh right but if some pop-up comes up and says this is gonna take a while we're loading the page for you we're aggregating the data then you're more likely to kind of wait for it right so then there's audit which is kind of something that we really really don't think think about much which is kind of verifying that the behavior of the application is correct you know did when my bank sent money do they log saying we transferred this much money from this account to this account and this accounts you know amount of money decreased by the same amount and this account increased right this is kind of double entry bookkeeping so what accountants do is they just look at the data from different angles and they just make sure everything lines up and this is something that your compliance departments might need the government might want like gdpr type stuff and the rest of the business might want because they want to know how many users of work you know are using the tool um is the number of subscribers going down every month which is obviously a bad thing um yeah so that's the the logging type table so purple slides again we're nearly at the end don't worry i'm just going to wrap up the sailing stuff so oh no i'm not i'm going to do this instead so the logging golden rules the three things to consider when you're writing logs and then i'm going to wrap up the same stuff remember the reader so this is who's reading the data is it going to be parsed are they going to be unable to understand what's going on do they know the context no personal data no passwords i've seen that a lot no passwords no usernames no email addresses um depends on the context obviously and then answer the question think about what question are you trying to answer with these locks are you trying to answer how do we get here are you trying to answer are you functioning correctly are you trying to answer um answer this this random question that the marketing guy said hey i'd really love to know how many users log in every three seconds or every three days right if there's some specific thing that's that's kind of the question and you need to make sure that that's understandable in the logs itself okay sailing now we're on sailing so this was my log that i kept in a book with paper and pen i mean hardcore stuff right so there are a few things that we can we can kind of keep take note of that we can actually learn so this is event logging this is me saying i did this and it happened for this long so this is when i picked the boat up yeah you can see the oh well the day i picked the boat up and the first time i ran the test and it ran for kind of three seconds then you can see something went wrong because suddenly my build pump the thing that's supposed to stop me from sinking takes 12 seconds to do its job and then some engineer came in the middle of the day you'll see by the rest of the logs that it's kind of a weird time in the middle of the day he came and he fixed something and then ran it for 10 seconds so this is an abnormal log right so something different happened and then you can see something went wrong it's not immediately obvious but if you're kind of displaying this in a graph it's quite helpful that i actually missed the morning here i missed the morning on the second of the fourth and that's because uh we had more issues with our water heater and suddenly worrying about actually being able to drink water was more important than uh than measuring how long our build pump ran for so that's something else went wrong and then that's when i ran that just before i dropped the boat off so another interesting thing is after the the tests after the guy fixed it these tests are all very similar even though the amount of rain changes right so the actual test runs change um so don't change much sorry which means there's probably a lot of overhead in in the pump from spinning up right but there's a lot of overhead and you can tell because the values are similar not because they're different so similarities in logs is still really really handy okay that's it you can drink more beer eat more pizza cool\n"