liveBook · Manning

Chapter 5: Making the most of logs: Auditing an app’s behavior

What you will learn in chapter 5 of Troubleshooting Java: Read, debug, and optimize JVM applications

This introduction explains how logs help investigate application behavior, what a useful log message contains, and why logs are a good starting point for investigations.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains how logs help investigate application behavior, what a useful log message contains, and why logs are a good starting point for investigations.

Key terms: log messages, Heisenbugs, timestamp, severity, log message, logs, debugger

5.1 Investigating issues with logs

This section contrasts logs’ view of past execution with a debugger’s focus on the present and explains how timestamps help interpret log messages.

Key terms: log messages, debugger, execution stack trace, timestamp, time zone, log message

5.1.1 Using logs to identify exceptions

This section explains how logged exceptions provide a starting point for investigation while cautioning that their root causes may lie elsewhere.

Key terms: logs, exception stack trace, debugger, profiler, NullPointerException, root cause, object instance, reference

5.1.2 Using exception stack traces to identify what calls a method

This section shows how to log an exception stack trace to identify the runtime caller of a method without a debugger.

Key terms: exception stack trace, execution stack trace, execution flow

5.1.3 Measuring time spent to execute a given instruction

This section explains how temporary timing logs can help identify slow code and troublesome database query parameters.

Key terms: log messages, timestamp, execution time, query, query execution time, parameter values, index, logs

5.1.4 Investigating issues in multithreaded architectures

This section explains how logs can help investigate multithreaded execution with less interference and identify the order and threads involved in operations.

Key terms: multithreaded architecture, debugger, profiler, logs, timestamp, log messages, thread name

5.2 Implementing logging

This section introduces upcoming discussions of logging implementation practices, including persistence, severity classification, and avoiding problems.

5.2.1 Persisting logs

This section explains why logs must be persisted and compares storage choices by performance, consistency, and usability.

Key terms: persistence, log messages, nonrelational database, NoSQL, performance, consistency, timestamp, ELK stack, relational database, financial apps

5.2.2 Defining logging levels and using logging frameworks

This section explains logging severities and demonstrates how to write and configure selective logs with Log4j.

Key terms: logging levels, severities, error, warn, info, debug, log severity pyramid, critical issues, Log4j, Logger

5.2.3 Problems caused by logging and how to avoid them

This section explains security, performance, and maintainability risks caused by logging and ways to reduce them.

Key terms: security, privacy, private keys, personal data, secrets vault, I/O stream, log messages, performance, logging levels, logging configuration

5.3 Logs vs. remote debugging

This section compares logs and remote debugging for investigating remotely running applications.

Key terms: debugging, logging, current state, timeline, adding extra logs, remote debugging, network configurations, permissions, logs

5.4 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 4: Debugging apps remotely Chapter 6: Identifying resource consumption problems using profiling techniques →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.