test_logger = logging.getLogger('Test')
handler = logging.handlers.RotatingFileHandler(file_name, maxBytes=10 ** 9)
test_logger.addHandler(handler)
How do I limit a file size when writing to files in python