0

I have a Java process. I am using log4j for logging purpose. I have specified in log4j.xml, location and name of log file. logging is working fine. I have problem with kill -3 logs here.

I trying to get process-dump using kill -QUIT <pid>/ killl -3 <pid>. I expected the dump generated by kill -3 to get updated in log file specified in log4j.xml.

But it is not happening that way. I need the dump to observer thread statuses. I do not know any other way to get process dump of a running process.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Learn More
  • 1,535
  • 4
  • 29
  • 51
  • Not using buffering. I have not specified it explicitly. I do not know how log4j handles flushing by default. Also, the link you pointed to, informs about flushing logs on shutdown. Here, I am not kill the process at all. I am merely using kill -QUIT to get thread dumo. – Learn More Jan 18 '13 at 08:55
  • @Oleg : I got it why this is happening. Log statements using logger object only going to configured file. Rest everything is redirected to stdout. Kill -QUIT dump is also getting redirected to stdout. – Learn More Jan 18 '13 at 11:12

2 Answers2

1

I need the dump to observer thread statuses. I do not know any other way to get process dump of a running process.

You can use jstack for this.

NPE
  • 486,780
  • 108
  • 951
  • 1,012
1

kill -3 should output to stdout, so it should be wherever your stdout goes. If not you could try playing with -XX:LogFile JVM option.

Alternative way is jstack as suggested by NPE.

Another alternative is to use jvisualvm - it will produce stackdump in its nice GUI and you can copy it from there.

Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95