background
Arthas
It is Alibaba's open source Java diagnostic tool.
github open source address: GitHub - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java Diagnostic Tool Arthas
Getting Started Tutorial
1. Download arthas and test run the demo
curl -O https://arthas.aliyun.com/arthas-boot.jar java -jar arthas-boot.jar
2. idea configure arthas command auxiliary plug-in
Search in the idea plug-in repository: arthas idea
Plug-in introduction: arthas idea - IntelliJ IDEs Plugin | Marketplace
Run a demo
1. I wrote a java demo to test the use of arthas
public class Demo {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
getInfo(String.valueOf(i));
}
}
private static void getInfo(String params) {
System.out.println(params);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
2. Use the plug-in, right-click the method and find the appropriate arthas command.
What I have here: trace -E arthas.Demo|formal.util.date.Display getInfo|main -n 5 --skipJDKMethod false '1==1'
3. Start the java process
4. Start arthas and change the default port to prevent port conflicts
java -jar arthas-boot.jar --telnet-port 9998 --http-port -1
5. Select the corresponding java process, enter arthas, and then paste the above arthas command into it
trace -E arthas.Demo|formal.util.date.Display getInfo|main -n 5 --skipJDKMethod false '1==1'