Logger's sync and flush returns NoMethod error

Hi,

Below is my code, which works fine in Ruby 1.8.6 (with Rails 2.3.5),
except that sync and flush both return NoMethod. Have thos methods
been eliminated?

Thanks in Advance,
Richard

equire ‘rubygems’
require ‘active_record’

class Account < ActiveRecord::Base
set_table_name “accounts”
has_many :comments
end

class Comment < ActiveRecord::Base
set_table_name “comments”
belongs_to :account
end

ActiveRecord::Base.establish_connection(
:adapter => ‘mysql’,
:host => ‘localhost’,
:database => ‘test’,
:username => ‘root’,
:password => “rlmrlm”)

mylog = Logger.new(‘mylog.txt’)

mylog.sync = true # NoMethod

error
ActiveRecord::Base.logger = mylog
temp = Account.find(1)
mylog.info(“Found a record with username: #{temp.username}” )
mylog.info(‘About to show comments’)
temp.comments.each do |rec|
puts “#{temp.username} said #{rec.subject}”
end
#mylog.flush # NoMethod
error

RichardOnRails wrote:

Below is my code, which works fine in Ruby 1.8.6 (with Rails 2.3.5),
except that sync and flush both return NoMethod. Have thos methods
been eliminated?

sync= and flush are instance methods on IO objects. I don’t think Logger
has them. Do you have anything which suggests that it does/did?

Hi Brian,

sync= and flush are instance methods on IO objects. I don’t think Logger
has them. Do you have anything which suggests that it does/did?

I found these on
http://maintainablesoftware.com/articles/rails_logging_tips

I was particularly interest in some flush capability the Logger seemed
to truncate the last logged msg.

Thanks for responding.

Best wishes,
Richard

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs