Advanced Debugging Techniques in IntelliJ IDEA: Log, Field, Exception, and Method Breakpoints
This article introduces four powerful IntelliJ IDEA debugging techniques—adding log statements at breakpoints, using field breakpoints, configuring exception breakpoints, and setting method breakpoints—to help developers efficiently trace code execution and inspect variables without cluttering the source.
Many developers rely on print statements for quick debugging, but forgetting to remove them can pollute the codebase and log tree. IntelliJ IDEA’s Evaluate and Log at Breakpoints feature lets you log values without modifying source code.
Log at Breakpoint
Place a breakpoint, press Shift + Left Click , and enable Evaluate and log . Enter an expression such as "interested" + i to log the value each time the breakpoint is hit. The logs appear only in Debug mode.
interested 7
interested 5
interested 1
interested 2
interested 0
Found 2 interested valuesYou can also enable the "Breakpoint hit" message to see the exact location of each hit, and optionally include a stack trace for deeper insight.
Field Breakpoints
To track where a field’s value changes, add a breakpoint on the field declaration (the eye icon appears), right‑click it, and enable Field access and Field modification . You can further restrict it with a Condition if needed.
Exception Breakpoints
When you want the debugger to stop before an exception is thrown, add an Exception Breakpoint for the specific exception type (e.g., NumberFormatException ). This pauses execution at the throw point, allowing you to inspect variable states.
Method Breakpoints
For interfaces or abstract methods with multiple implementations, set a breakpoint on the method signature (using cmd+F8 or ctrl+F8 ), right‑click the breakpoint, and optionally add a Condition . When debugging, IntelliJ will jump directly to the concrete implementation that is invoked.
These four breakpoint techniques—log, field, exception, and method—significantly streamline both everyday debugging and source‑code exploration, reducing manual logging and improving code‑review efficiency.
Below is a summary image of all breakpoint types supported by IntelliJ IDEA:
Code Ape Tech Column
Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.