Detailed explanation of Haproxy log configuration in Linux

Source: Internet
Author: User
Tags system log haproxy rsyslog

Haproxy The log is not logged by default, and the configuration file for the system log is required, in addition to specifying the output of the log in the global segment in haproxy.conf. Take centos6.4 as an example, Haproxy uses the system's own RPM newspaper version 1.4

1, vim/etc/haproxy/haproxy.conf

Global
Log 127.0.0.1 Local3 #local3是设备, corresponding to the configuration in/etc/rsyslog.conf, the default recycle info logging level
Maxconn 1024
User Haproxy
Group Haproxy
Daemon
Pidfile/var/run/haproxy.pid
Defaults
Mode http
Log Global
Option Httplog
Option Dontlognull
Option Http-server-close
Option Forwardfor except 127.0.0.0/8
Retries 2
Option Redispatch
Maxconn 1024

2. Edit System Log Configuration

Vim/etc/rsyslog.conf

By default, the following settings will read the configuration file in the/etc/rsyslog.d/*.conf directory

$IncludeConfig/etc/rsyslog.d/*.conf
Create a separate configuration file for Haproxy

Vim/etc/rsyslog.d/haproxy.conf
$ModLoad IMUDP
$UDPServerRun 514
local3.*/var/log/haproxy.log
The message file is also written to the log in Aproxy.log
&~

3, configure the Rsyslog of the main configuration file, open the remote log

Vim/etc/sysconfig/rsyslog
Syslogd_options= "-C 2-r-M 0″
#-c 2 uses compatibility mode, the default is-C 5
#-r Open Remote Log
#-m 0 marks the timestamp. The unit is minutes, 0 o'clock, which means that the feature is disabled

Restart Haproxy and Rsyslog services after configuration is complete

/etc/init.d/rsyslog restart
/etc/init.d/haproxy restart

4, on the Red Hat 5 configuration system log and Red Hat 6 different, Red Hat 5/etc/rsyslog.conf does not contain/etc/rsyslog.d/*.conf, configured as follows

#加入haproxy. None indicates that the Haproxy log is not written to the message
*.info;mail.none;authpriv.none;cron.none;haproxynone/var/log/messages
local3.*/var/log/haproxy.log

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.