Passing logs from JNI to JVM side
843829May 3 2009 — edited May 7 2009Hello everybody,
I have application which works both in standalone and Web Start modes. It also uses JNI widely.
I have a specific error when launching application in Web Start mode. There is no such error in standalone mode. In order to find out the difference I would rely on debug messages, but there was a catch.
In Web Start mode I am able to see only those messages that were put into System.out. They are displayed in Java Console.
Logs which are put into stdout by native side are not displayed in Java Console and I can not figure out what happens there.
I have an idea to pass all native debug messages onto JVM side and then put them into System.out as well.
Currently I use log4j on JVM and log4cpp on native side.
The pitfall I suspect there is about having to deal with JNIEnv pointer. I'd like to delegate the responsibility of passing jstring containing the message to a dedicated log4cpp logger. But in that case logger will have to deal with number of JNIEnv pointers one for each single thread.
What do you think about it? Is there better solution than this?
Thank you,
Alex.
Edited by: Alexander_P on May 3, 2009 1:03 AM