Boost Java Debugging: Solve Production Issues in 5 Minutes with Arthas
This guide demonstrates how to replace traditional debugging with Arthas, covering installation of IDEA plugins, quick 5‑minute problem resolution, hot‑deployment using ArthasHotSwap, and advanced time‑tunnel commands for recording and replaying method executions.
Introduction
Debugging in production is often inefficient; Arthas can replace traditional debugging to improve daily development efficiency.
Prerequisites
Install the IDEA plugins “Arthas Idea” and “ArthasHotSwap”. The former helps generate Arthas commands, the latter enables simple hot‑deployment.
5‑Minute Problem Solving
Problem description : An interface returns a null parameter without logs, making debugging difficult.
Step 1 – Locate the method : Identify the target method and use watch to observe its parameters and return values.
Step 2 – Generate watch command : Right‑click the method name in IDEA and select “watch”. The command is copied to the clipboard.
Step 3 – Log into the remote server and run Arthas.
Step 4 – Install Arthas (one‑line install):
curl -L https://arthas.aliyun.com/install.sh | shStep 5 – Start Arthas : Execute ./as.sh to enter the interactive console.
Step 6 – Execute the watch command (example):
watch com.**.**.endpoint.BargainPlayApplyCycleEndPoint fetchPlayDetailRenderData '{params,returnObj,throwExp}' -n 5 -x 3 'params[0].getPlayToolDO().getId()==588'Explanation of the command options follows.
Step 7 – View results : The observed parameters reveal that targetId is null, leading to the root cause.
Further solution : Use ArthasHotSwap to hot‑replace the class without redeploying. After swapping, the issue is resolved and the front‑end displays correctly.
Limitations
Arthas redefine cannot change method names or fields, only the method body. Certain commands may conflict after a redefine, and ThreadLocal information can be lost during hot‑deployment.
Time Tunnel (tt) Commands
The tt command records method execution history, allowing replay, filtering, and inspection.
Record execution: tt -t List records: tt -l Search records: tt -s 'params[2].getRecordId() == 110213603' Watch a record: tt -w Replay a record: tt -p -i 1000 (or with repeat options)
Be aware that tt only stores a single object reference; changes after the call may not be reflected, which is why watch remains useful.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Developer
Alibaba's official tech channel, featuring all of its technology innovations.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
