chapter four
                    4 Making the most of logs: Auditing an app’s behavior
This chapter covers
- Using log messages to understand an app’s behavior
 - Correctly implementing log capabilities in your app
 - Using AI assistants to investigate large log files
 - Avoiding problems caused by logs
 
This chapter discusses using log messages recorded by an app. The concept of logging didn’t appear with software. For centuries, people used logs to understand past events and processes better. In fact, people have used logging since writing was invented, and we still use it today. All ships have logbooks. Sailors record decisions (direction, speed increase or decrease, etc.) and given or received orders, along with any encountered event (figure 4.1). If something happens to the onboard equipment, they can use the logbook notes to understand where they are and navigate to the nearest shore. If an accident happens, the logbook notes can be used in the investigation to determine how the unfortunate event could have been avoided.
Figure 4.1 Sailors store events in logs that they can use to determine their route or analyze the crew’s response to a given event. In the same way, apps store log messages so that developers can later analyze a potential problem or discover breaches in the app.