跟踪Java方法执行
我很难找到追踪方法执行的方法(例如:执行时调用方法。)
这是我要跟踪的代码段:
@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;
}
我想知道方法 sanitize jsonsanitizer 类的强>
我尝试运行JSTACK,但是我看不到Jsonsanitizer.sanitize.sanitize方法在堆栈跟踪中。
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在代码中添加日志语句,将信息写入日志文件或 System.out,或者您可以在调试模式下运行应用程序,并在代码中添加一个断点,从您想要开始跟踪所发生情况的位置开始。当代码执行到断点时,调试器将暂停执行,您可以逐条执行/进入/退出语句。
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.