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!