You will have to create a log service in order for haproxy to be able to log to specific files. Use following instructions, which worked for me in EL7 and HAProxy 2.7-dev5:-
yum install rsyslog
vi /etc/rsyslog.d/haproxy.conf
$ModLoad imudp $UDPServerAddress 127.0.0.1 $UDPServerRun 514 local2.* /logdir/haproxy local3.* /logdir/haproxy-access_log systemctl restart rsyslog && ldconfig
vi /../../haproxy.cfg
global log stderr local0 info log 127.0.0.1 local2 notice log 127.0.0.1 local3 defaults log global option httplog systemctl restart haproxy
Don't forget to setup log rotation service as well, to avoid unnecessary space consumption and following should do the job:-
vi /etc/logrotate.d/haproxy
/logdir/logdir/haproxy-access_log { weekly rotate 7 missingok size=5M notifempty dateext dateformat -%d%m%Y compress create 0644 logfileowner logfileowner su logfileowner logfileowner mail email@torecievelogs postrotate /usr/bin/systemctl reload haproxy endscript } Also, run the following two commands to find out if there is any problem with log rotation:-
logrotate --force /etc/logrotate.d/haproxy grep logrotate /var/log/audit/audit.log | audit2why Lastly, hereby I note if security-enhanced is enabled you might need to tweak log files context and its parent directory.
Good luck :).
Zakaria.