“Haproxy日志配置”的版本间的差异
来自Dennis的知识库
Dennis zhuang(讨论 | 贡献) (以“ /etc/haproxy/haproxy.cfg开启日志: ``` global #log 127.0.0.1 local0 #log 127.0.0.1 local1 notice log /dev/log local0 info log /dev/log local0 notice ```”为内容创建页面) |
Dennis zhuang(讨论 | 贡献) |
||
第1行: | 第1行: | ||
− | /etc/haproxy/haproxy.cfg开启日志: | + | 1. /etc/haproxy/haproxy.cfg开启日志: |
− | + | global | |
− | global | + | log /dev/log local0 info |
− | + | log /dev/log local0 notice | |
− | + | ||
− | + | ||
− | + | 2. 配置rsyslog: /etc/rsyslog.d/haproxy.conf | |
− | + | ||
+ | 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 | ||
+ | & ~ | ||
+ | |||
+ | 3. 配置日志切换: /etc/logrotate.d/haproxy | ||
+ | |||
+ | /var/log/haproxy/*.log { | ||
+ | daily | ||
+ | missingok | ||
+ | rotate 28 | ||
+ | compress | ||
+ | delaycompress | ||
+ | notifempty | ||
+ | create 644 root adm | ||
+ | sharedscripts | ||
+ | postrotate | ||
+ | /etc/init.d/haproxy reload > /dev/null | ||
+ | endscript | ||
+ | } | ||
+ | |||
+ | 4.重启rsyslog和haproxy | ||
+ | |||
+ | sudo restart rsyslog | ||
+ | sudo /etc/init.d/haproxy restart |
2013年12月3日 (二) 09:10的版本
1. /etc/haproxy/haproxy.cfg开启日志:
global
log /dev/log local0 info log /dev/log local0 notice
2. 配置rsyslog: /etc/rsyslog.d/haproxy.conf
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 & ~
3. 配置日志切换: /etc/logrotate.d/haproxy
/var/log/haproxy/*.log {
daily missingok rotate 28 compress delaycompress notifempty create 644 root adm sharedscripts postrotate /etc/init.d/haproxy reload > /dev/null endscript
}
4.重启rsyslog和haproxy
sudo restart rsyslog sudo /etc/init.d/haproxy restart