JVM thread dump location

后端 未结 4 1259
后悔当初
后悔当初 2021-01-01 19:56

When I issue a kill -3 command to my Java program, it generates the thread dump on the console. How do I redirect this to a file?

4条回答
  •  悲&欢浪女
    2021-01-01 20:31

    Two options:

    Run your Java application with stdout redirected

    java com.example.MyApp > out.txt
    

    Use jstack instead.

    The jstack utility allows you to get a thread dump and send the output to the current console instead of the stdout of the Java application, allowing you to redirect it.

    For example, if the PID of your Java application is 12345 (use the jps utility to find it quickly):

    jstack 12345 > threads.txt
    

提交回复
热议问题