Daily logger not working?

Hi,

In my controller I have given:

logger = Logger.new(‘try.log’, shift_age=‘daily’)

A file is created in the root folder of my application as try.log.

But if I give logger.info(‘testing’) then this is logged in
development.log instead of try.log. Am I missing some setup?

If you want a controller specific logger, you should over-write the
the inherited @logger attribute and provide an accessor for it.

attr_accessor :logger
def initialize
super
@logger = Logger.new(‘try.log’)
end

If you want a rails-wide logger over-ride, you’ll need to do it in
config/environment*

One caveat – in clustered setups using Ruby-specific log rotation is
a huge no-no and will cause you massive headaches in the future. You
should rely on some sort of external log rotation solution (logrotate,
etc) for those.

Can you point me as to where I can get an idea of external log rotation?

There are a few packages out there. This is what I use:
http://iain.cx/src/logrotate/

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