0

Because you cannot redirect GC logs I am left with the option to redirect it to a file with -Xloggc and then get the contents of this file inside my selector through a file channel of some kind. Basically as lines are being added to my file, the selector is being triggered to read them. That way I can get the GC logs programmatically. Is it possible to do that using NIO?

Community
  • 1
  • 1
chrisapotek
  • 6,007
  • 14
  • 51
  • 85

2 Answers2

0

No. FileChannel does not extend SelectableChannel so you can't select with it, and even in C where you can, select() doesn't deliver readable events when the file is extended (it delivers them every time you select, as the file is always readable).

user207421
  • 305,947
  • 44
  • 307
  • 483
0

Given GC logs are buffered, I wouldn't worry about a bit of latency. You can just poll the file length periodically and read the data added each time. You can do this in IO, NIO or NIO2.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130