In some case, HAproxy work better than Nginx ,but I need to log an user-agent .
defaults
log-format "%{+Q}o \"%{-Q}ci\" %r %hrl %ST %B %cp %ms %ft %b %s %TR %Tw %Tc %Tr %Ta %tsc %ac %fc %bc %sc %rc %sq %bq %CC %CS"
and the important part.
frontend www-https
capture request header user-agent len 200
Output:
done