I have a JRuby project that requires a Java jar. The Java jar is instrumented for logging using log4j. I don't need to use log4j in my JRuby code, but I want to run the JRuby code so that when the instrumented Java classes are called they respect the log4j settings I've specified.
I'm using Trinidad and had hoped that just passing in the 'normal' log4j JVM arguments would do the trick. Here's the process information when I just run Trinidad:
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -Xmx500m -Xss2048k -Djffi.boot.library.path=/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib/jni -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Xbootclasspath/a:/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib/jruby.jar -classpath : -Djruby.home=/Users/eebbesen/.rvm/rubies/jruby-1.7.5 -Djruby.lib=/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main script/trinidad
and here's what I tried to get log4j working:
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -Xmx500m -Xss2048k -Djffi.boot.library.path=/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib/jni -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Xbootclasspath/a:/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib/jruby.jar -classpath : -Djruby.home=/Users/eebbesen/.rvm/rubies/jruby-1.7.5 -Djruby.lib=/Users/eebbesen/.rvm/rubies/jruby-1.7.5/lib -Djruby.script=jruby -Dlog4j.debug=true -Dlog4j.configuration=file:log4j.properties -Djruby.shell=/bin/sh org.jruby.Main script/trinidad
so I'm just adding
-Dlog4j.debug=true -Dlog4j.configuration=file:log4j.properties
to what Trinidad is already doing.
What I'm not seeing is any of the log4j logging happening when I run Trinidad. However, when I use Rails console my logging statements are appearing.
The posts I've seen cover how to use log4j from within JRuby, but I would like to accomplish this via JVM arguments if possible.