Logging with log4j on tomcat jruby-rack for a Rails 3 application

后端 未结 2 360
一整个雨季
一整个雨季 2020-12-31 20:34

I just spent the better part of 3 hours trying to get my Rails application logging with Log4j. I\'ve finally got it working, but I\'m not sure if what I did is correct. I tr

相关标签:
2条回答
  • 2020-12-31 20:56

    We also did various experiments and finally settled with slf4j option. Coming from Java background we knew slf4j, so we didn't go further.

    <context-param>
       <param-name>jruby.rack.logging</param-name>
       <param-value>slf4j</param-value>
     </context-param>
    

    btw, there is no need to copy slf4j-simple-1.6.1.jar into tomcat/lib or WEB-INF/lib when using slf4j-log4jxxx.jar

    0 讨论(0)
  • 2020-12-31 21:01

    It's possible that your early tests with commons-logging were showing zero bytes files because of bufferSize.

    If your entries get flushed to the file when you stop Tomcat then this is indeed the case and you are falling foul of the default 8Kb buffer.

    To disable, for immediate flushing try...

    org.apache.juli.FileHandler.bufferSize = -1

    on the specific handler...

    So for localhost...

    2localhost.org.apache.juli.FileHandler.bufferSize = -1

    0 讨论(0)
提交回复
热议问题