How do I log in common.log file?
abhijitnandy opened this issue · 2 comments
abhijitnandy commented
I have the following set up for the production environment
LOGGER = Logger.new('common.log', 'weekly')
LOGGER.level = Logger::INFO
I've also added the plugin like so -
class App < Roda
if ENV['RACK_ENV'] == 'production'
plugin :enhanced_logger
end
route do |r|
...
end
end
The logs get shown in the std.out
file. I would prefer the logs to be shown in the common.log
file.
How would I go about doing this? I had a look at the examples but didn't see anything for this.
Thanks.
adam12 commented
You could pass the :output
option to the plugin, but it expects something that TTY::Logger
would support. In your case, this wouldn't be 1-1 equivalent since TTY:Logger
doesn't support log rotation (AFAIK).
So you could provide common.log
via an open File
handle perhaps, and then handle log rotation through something like the logrotate
tool?
plugin :enhanced_logger, output: File.open("common.log", "a")
abhijitnandy commented
Thanks for the suggestion. Closing this issue from my side.