← 返回命令列表

Linux command

arthas-watch 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Watch

watch [com.example.MyClass] [myMethod] returnObj

Example

watch [com.example.MyClass] [myMethod] '{params, returnObj}'

Example

watch [com.example.MyClass] [myMethod] returnObj 'returnObj != null'

Example

watch [com.example.MyClass] [myMethod] '{params, throwExp}' -e

Example

watch [com.example.MyClass] [myMethod] '{params, returnObj}' -x 3

说明

watch is an Arthas command that observes method arguments, return values, and exceptions in real-time. It uses OGNL expressions to extract and display specific data from method invocations. This enables debugging production issues without stopping the application or adding logging code.

参数

class-pattern
Class name (supports wildcards)
method-pattern
Method name (supports wildcards)
express
OGNL expression for what to watch
-b
Watch before method execution
-e
Watch on exception
-s
Watch on success return
-f
Watch on finish (both success and exception)
-n _count_
Stop after count invocations
-x _depth_
Expand object depth (default: 1, max: 4)
-M _size_
Maximum size limit for output
condition-express
Filter condition (OGNL)

FAQ

What is the arthas-watch command used for?

watch is an Arthas command that observes method arguments, return values, and exceptions in real-time. It uses OGNL expressions to extract and display specific data from method invocations. This enables debugging production issues without stopping the application or adding logging code.

How do I run a basic arthas-watch example?

Run `watch [com.example.MyClass] [myMethod] returnObj` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does class-pattern do in arthas-watch?

Class name (supports wildcards)