Arthas官方介绍
Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。
使用
安装
下载: wget https://alibaba.github.io/arthas/arthas-boot.jar
启动: java -jar arthas-boot.jar
常用命令
watch
查看方法返回的结果
watch -f com.xx.package.method param returnObj -x 3
同时观察 入参和返回结果
watch -f com.xx.package.method param {params,returnObj}
过滤指定参数的执行结果
watch -f com.xx.package.method param {params,returnObj} ‘params[0]==“012333”’ -x 3
watch的更多使用,参考官方文档:https://arthas.aliyun.com/doc/watch.html
优势:遇到问题时,不再需要增加日志代码排查问题
不需要重新发布代码,真爽啊
参数说明
参数说明:
“{params,returnObj}” 两个变量就是代表参数,返回值
-x 指定输出结果(默认为1) 这里为2层
-b 表示在方法调用之前
-e 表示在方法出异常时
-s 表示在方法返回之后
-f 表示在方法结束之后(正常返回和异常返回)
参考文档:
https://www.cnblogs.com/alisystemsoftware/p/13087196.html
https://arthas.aliyun.com/doc/watch.html