colbygk / log4r

Log4r is a comprehensive and flexible logging library for use in Ruby programs. It features a heirarchical logging system of any number of levels, custom level names, multiple output destinations per log event, custom formatting, and more.
Other
251 stars 88 forks source link

thread name output is not nice with jruby #9

Open nicobrevin opened 12 years ago

nicobrevin commented 12 years ago

if you haven't set Thread['name'](which sometimes you can't do nicely if you are working with third party libs), the thread name in the output comes out as #Thread:0x3b6c57b1

I've hacked around it with the following...

Log4r::PatternFormatter::DirectiveTable['h'] = 
  'Thread.current[:name] || Java::JavaLang::Thread.currentThread.name'

So it uses Thread[:name] at first, but falls back to the Java thread name if it isn't set. Could we add this in to log4r somehow?

reidmorrison commented 8 years ago

Don't see much activity here anymore, have you tried Semantic Logger? It has direct support for JRuby thread names, and also allows you to set your own thread names so that they show up correctly in the log files. Also logs JVM garbage collection events along with their duration.