class RotateUserAgentMiddleware(UserAgentMiddleware):

    def __init__(self, user_agent=''):
        self.user_agent = user_agent

def process_request(self, request, spider):
    ua = random.choice(self.user_agent_list)
if ua:
    request.headers.setdefault('User-Agent', ua)
spider.log('User-Agent: {} {}'.format(request.headers.get('User-Agent'),
    request), level=log.DEBUG)
How to make Scrapy show user agent per download request in log?