跟踪Java方法执行

发布于 2025-01-20 15:40:46 字数 602 浏览 4 评论 0原文

我很难找到追踪方法执行的方法(例如:执行时调用方法。)

这是我要跟踪的代码段:

@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只涨不跌 2025-01-27 15:40:46

您可以在代码中添加日志语句,将信息写入日志文件或 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文