Hi all,
I’m trying to get Jetty’s logging under control. By default it logs to
$stderr, but I’d like to give it a Log4r logger to use.
Jetty uses a static block to configure the logger, which passes the name
of the class to load via System.get/setProperty - in short, if I can
System.setProperty(“org.mortbay.log.class”, ), where
indicates my Log4r::Logger subclass, I should be set.
Doing the obvious - System.setProperty(“org.mortbay.log.class”,
“Log4r.Logger”) - doesn’t have the desired effect. Has anyone else got
this to work?
I’m on jruby-1.5.1, 'cos that’s what’s in Debian Squeeze.
Thanks,
Alex
Oh, nearly forgot - I’m using jetty via the rack-jetty gem, which
packages jetty-6.1.14.
Thanks,
Alex
Nick S. wrote in post #964822:
On Mon, Nov 29, 2010 at 9:40 AM, Alex Y. [email protected]
wrote:
Doing the obvious - System.setProperty(“org.mortbay.log.class”,
“Log4r.Logger”) - doesn’t have the desired effect. Has anyone else got
this to work?
I’m on jruby-1.5.1, 'cos that’s what’s in Debian Squeeze.
I’m not familiar with the rack-jetty gem, but you may need to find a
way to have the system property set before the jetty classes get
loaded.
Yeah, that’s as far as I got.
Note that the Jetty property probably only takes a Java class name, so
if you want to actually use Log4r you might have to pre-compile a Ruby
class with “jrubyc --javac”. Here’s an example:
java-from-ruby-examples/compile at master · nicksieger/java-from-ruby-examples · GitHub
Ah, thanks. So there’s no way to do that at runtime?
–
Alex
On Mon, Nov 29, 2010 at 9:40 AM, Alex Y. [email protected]
wrote:
Doing the obvious - System.setProperty(“org.mortbay.log.class”,
“Log4r.Logger”) - doesn’t have the desired effect. Has anyone else got
this to work?
I’m on jruby-1.5.1, 'cos that’s what’s in Debian Squeeze.
I’m not familiar with the rack-jetty gem, but you may need to find a
way to have the system property set before the jetty classes get
loaded. You can either write a wrapper script around rack-jetty or set
on the command-line:
jruby -J-Dorg.mortbay.log.class=my.Logger -S rack-jetty ...
Note that the Jetty property probably only takes a Java class name, so
if you want to actually use Log4r you might have to pre-compile a Ruby
class with “jrubyc --javac”. Here’s an example:
/Nick
On Tue, Nov 30, 2010 at 4:19 AM, Alex Y. [email protected]
wrote:
I’m not familiar with the rack-jetty gem, but you may need to find a
Ah, thanks. So there’s no way to do that at runtime?
Well, /maybe/. We do have the ‘jruby/core_ext’ library which adds a
#become_java! method to Class. It returns the Java Class object from
which you could receive the name.
Unfortunately #become_java! doesn’t currently use the same mechanisms
as jrubyc. You can see an example of #become_java! here:
/Nick