View Full Version : Unable to log to STDOUT from Ruby/Rails when running under LiteSpeed
dirkbj
11-01-2006, 04:25 PM
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
mistwang
11-02-2006, 11:44 AM
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.
dirkbj
11-02-2006, 11:52 AM
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.
mistwang
11-02-2006, 12:12 PM
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?
dirkbj
11-02-2006, 12:25 PM
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
mistwang
11-15-2006, 10:03 AM
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.