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.
@logger = Logger.new(‘try.log’)
If you want a rails-wide logger over-ride, you’ll need to do it in
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: