未分类 · 2025-06-30 0

arthas 使用

一、trace 查看方法的耗时

trace org.example.controller.StudentController sayInCtl

二、watch 查看方法的入参、返回值、抛出异常

函数执行数据观测,能方便的观察到指定函数的调用情况。
能观察到的范围为:返回值、抛出异常、入参,通过编写 OGNL 表达式进行对应变量的查看。

watch org.example.controller.StudentController sayInCtl "{params,returnObj,throwExp}" -x 3  

-x 3 是指定输出结果的属性遍历深度,默认为 1

三、stack 查看方法的调用链路

查看方法的调用链路

stack org.example.controller.StudentController sayInCtl

四、monitor

方法执行监控

monitor 命令是一个非实时返回命令.

五、heapdump

dump 到指定文件

heapdump arthas-output/dump.hprof

dump 到临时文件

heapdump

生成文件在arthas-output目录,可以通过浏览器下载: http://localhost:8563/arthas-output/