'Trace Java method execution
I am having a hard time finding a way to trace a method execution (ex: methods being called at execution..)
Here is the code snippet I want to trace:
@GetMapping("/test")
public String test(){
String jsonString = "{\"key1\":\"value1\",\"type\":\"Booking\",\"sid\":\"A43521\",\"region\":\"ASIA\","
+ "\"fetchFromFile\":\"false\",\"service\":\"true\",\"isEom\":\"true\",*#@!}";
String response = JsonSanitizer.sanitize(jsonString);
return response;
}
I'd like to know that the method sanitize of JsonSanitizer class has been called ..
I tried running jstack, but I don't see any occurences of JsonSanitizer.sanitize method in the stack traces.
Thanks in advance
Solution 1:[1]
You can either add log statements in your code, which write information to a log file or System.out for example, or you can run the application in debug mode and add a breakpoint in the code from where you want to start tracking what happens. When the code execution reaches the breakpoint, the debugger will pause execution and you can step through/in/out the statements one by one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Adriaan Koster |
