Unable to log to STDOUT from Ruby/Rails when running under LiteSpeed

Discussion in 'Ruby/Rails' started by dirkbj, Nov 2, 2006.

  1. dirkbj

    dirkbj New Member

    I have the following code in my Rails app:


    require 'logger'

    QGV_LOGGER = Logger.new(STDOUT)

    QGV_LOGGER.info "Logging engaged in #{RAILS_ENV} Rails environment"


    This runs fine when run using WEBrick, however, when run using LS 2.2.4, I get a "Broken Pipe" error.

    Does LS deny me access to STDOUT in Rails?

    Dirk
  2. mistwang

    mistwang LiteSpeed Staff

    Where does the log message go when logging to STDOUT? WEBrink console?
    I tried your code in a controller, it works, message goes to the production.log.
  3. dirkbj

    dirkbj New Member

    re: Unable to log to STOUT from Ruby/Rails when running under LiteSpeed

    Sorry I wasn't clearer. The error is a Rails error, so the logging goes nowhere... it is as if STDOUT is not a valid File pointer.
  4. mistwang

    mistwang LiteSpeed Staff

    I added the code in the first post inside a controller class of a test rails application. It works, and the log message goes into log/production.log.

    I wonder where you put those code to break rails?
  5. dirkbj

    dirkbj New Member

    Good question. I actually have the code in a class that doesn not inherit from any Rails class:


    class QuestionGroupValidator
    require 'logger'

    attr_accessor :validation_string

    QGV_LOGGER = Logger.new(STDOUT)

    QGV_LOGGER.info "Logging engaged in #{RAILS_ENV} Rails environment"

    #....
    end


    Thanks for the help!

    Dirk
  6. mistwang

    mistwang LiteSpeed Staff

    Still not able to reproduce the problem here.

    I think it might happen during Rails framework initialization, after the framework has been fully initialized, it just works fine.

Share This Page