Turnning off log rotation
I have some code I am maintaining that is using the logging ruby gem. I would like to use the linux logrotate tool instead of the gem to rotate the logs. I'm using it inside some custom code to create separate log streams.
require 'logging'
[...]
def create_logger(name)
logger = Logging.logger[name]
Is there a way I can turn off log rotation after the logger object is created?
logger.age = 0 is not working.
The logging gem does not enable any log rotation by default. It must be configured manually via the RollingFile appender.
I'd suggest searching through your code for references to RollingFile or rolling_file.
But to answer your original question, you would need to use the logger.remove_appenders method to remove the rolling file appender. Then you would have to add a regular file appender to replace the one you just removed.
The RollingFile appender does not provide hooks for dynamically changing the interval when log files are rotated.