JVM Thread Dump, System.setErr() System.setOut()
when you issue a QUIT signal ( kill -s QUIT pid ) against a java process, the VM dumps out a thread dump. This is valueable e.g. for thread blocking or deadlock analysis. For each thread a stacktrace is generated. To find out where processing hangs, its wise to initiate two thread dumps. Usual it dumps to unix channel 2 (std error output) but my JVM 1.3.1 dumps to std. out. if output is redirected into a logfile, these files are getting soon very large. we prefer to avoid problems like "no space left on device". a solution is using System.setOut(pw), System.setErr(). As the dump generating part of the VM seems to be a platform dependent handler, a redirection of output with the help of System.setOut/setErr does not affect the location of the file containing our thread dumps. usually output is redirected to /dev/null if your application e.g. tomcat has to discard std output because of large data amounts. you can preserve this but have your thread dumps logged in a file. Just redirect all VMs output in a file and when your server application started up, use System.setOut(pw)/setErr(pw) to redirect all output. with the help of a dummy outputstream class - which does nothing - you can instanciate a printwriter. with this, all logging stops, but thread dumps are still logged as the System.setOut calls have no effect on them.

0 Comments:
Kommentar veröffentlichen
<< Home