I am calling puts statements like this:
puts "something"
Within my Rails Resque workers. What is the best way to read this output real time? tail development.log?
Thanks!
You could always try to use the Logger
:
Logger.info "Something"
# Or
Logger.debug "Something"
# Or
Logger.error "Something"
These will definitely show up in your logs. :)
I recommend using Log4r:
In config/environments/*.rb
#format of message in logger
format = Log4r::PatternFormatter.new(:pattern => "%d - [%l]:\t%m.")
# log configuration
configlog = {
"filename" => "log/your_name.log",
"max_backups" => 28, # 7days * 4 files of 6 hours
"maxtime" => 21600, # 6 hours in sec
"maxsize" => 10485760, # 10MB in bytes
"trunc" => false
}
rolling = Log4r::RollingFileOutputter.new("rolling",configlog)
rolling.formatter = format
config.logger = Log4r::Logger.new("your_name.log")
config.logger.add(rolling)
Then in your code:
Logger.info "output"
Logger.debug "output"
In your_name.log you will see:
2013-08-07 10:00:47 - [INFO]: output
2013-08-07 10:00:47 - [DEBUG]: output
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.