I've encountered OutOfMemoryError in my JAVA program. It is OK that OutOfMemoryError happened, but I'd like to log it when it happens. I have used -XX:OnOutOfMemoryError options to detect that it happened, but it doesn't log stacktrace information which is printed to console. I tried to use redirection to log this console output, but 2>&1, 2>, and all other options failed log this output and it just printed to console. Is there any way to log this stacktrace information? I've been googling and searching in stackoverflow.com but couldn't find answer. Please advice.
- Heap Dump is not my option, either. I don't have so much space so can't risk such huge file :'( I just need to log stacktrace information.
Thank you!