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

#1
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

LiteSpeed Staff
#2
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
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.
 

mistwang

LiteSpeed Staff
#4
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
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

LiteSpeed Staff
#6
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.
 
Top