Possible to log X-FORWARDED-FOR to nginx error_log?

You should be using the real IP module, so that the client's actual IP address is considered the remote IP address, rather than your load balancer's IP address. This way, you won't have to check X-Forwarded-For in your logs, nor in your application either.

It is simple to enable it, just supply your load balancer IP address(es):

set_real_ip_from  10.0.0.0/8;
set_real_ip_from  172.16.0.0/12;
set_real_ip_from  192.168.0.0/16;
real_ip_header    X-Forwarded-For;