Haproxy high-availability logging configuration file

Source: Internet
Author: User
Tags haproxy rsyslog

With regard to haproxy log configuration, We separately describe that the default haproxy log is output to the system syslog, which is not very convenient to view. In order to better manage haproxy logs, we generally define them separately in the production environment. The method is as follows:

First, modify the log configuration options of haproxy and add the following Configuration:

Log/dev/log local0 info

Log/dev/log local0 notice

Note: These two configurations are placed in the global configuration project of haproxy, which records the info and notice logs of haproxy to different log files respectively.

If you follow the configurations in this document, modify the global configuration in the configuration file to the following Configuration:

Global

Log/dev/log local0 info

Log/dev/log local0notice

Maxconn 4096 // maximum number of connections

UID 99 // user uid

GID 99 // user GID

Restart haproxy to complete haproxy Configuration

Again, we need to modify the rsyslog configuration. To facilitate management, we define the haproxy-related configuration independently to haproxy. conf and put it in/etc/rsyslog. d/. When rsyslog is started, all configuration files under this directory are automatically loaded.

# Touch/etc/rsyslog. d/haproxy. conf

# Vim/etc/rsyslog. d/haproxy. conf

Add the following content:

If ($ programname = 'haproxy' and $ syslogseverity-TEXT = 'info') then-/var/log/haproxy/haproxy-info.log

&~

If ($ programname = 'haproxy' and $ syslogseverity-TEXT = 'notice ') then-/var/log/haproxy/haproxy-notice.log

&~

Note:

This configuration is to record the info log of haproxy to/var/log/haproxy/haproxy-info.log and record the notice log to/var/log/haproxy/haproxy-notice.log.

Save the configuration file and restart the rsyslog service to complete rsyslog configuration.

Finally, we can use tail-F/var/log/haproxy/haproxy-info.log to view the haproxy access request log information.

650) This. width = 650; "src ="/e/u261/themes/default/images/spacer.gif "style =" Background: URL ("/e/u261/lang/ZH-CN/images/localimage.png") No-repeat center; Border: 1px solid # DDD; "Height =" 74 "width =" 814 "alt =" spacer.gif "/>

This article is from the "john_in_two" blog. For more information, contact the author!

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.