We are using a dll with JNA in our java project. We would like the C code to also log to our log4j log files, is there an easy way of doing this?
Asked
Active
Viewed 367 times
1 Answers
0
Not easily, really. I can think of a few ways
- call a Java program within your C code that just calls log4j (slow, you have to load up Java for each logging call)
- leave a Java process running that accepts log requests (communicate with the process using one of the options here Good alternative to shared memory IPC for Java/C++ apps on Linux)
- use GCJ to natively compile a Java program that calls log4j, then link it to your C program

Community
- 1
- 1

artbristol
- 32,010
- 5
- 70
- 103