“Haproxy日志配置”的版本间的差异
来自Dennis的知识库
Dennis zhuang(讨论 | 贡献) |
Dennis zhuang(讨论 | 贡献) |
||
(未显示1个用户的1个中间版本) | |||
第3行: | 第3行: | ||
global | global | ||
− | + | log 127.0.0.1 local0 | |
− | + | log 127.0.0.1 local1 notice | |
+ | |||
+ | |||
+ | defaults配置: | ||
+ | |||
+ | defaults | ||
+ | log global | ||
2. 配置rsyslog: /etc/rsyslog.d/haproxy.conf | 2. 配置rsyslog: /etc/rsyslog.d/haproxy.conf | ||
− | if ($programname == 'haproxy | + | if ($programname == 'haproxy') then -/var/log/haproxy.log |
− | + | ||
− | + | ||
− | + | ||
3. 配置日志切换: /etc/logrotate.d/haproxy | 3. 配置日志切换: /etc/logrotate.d/haproxy | ||
− | /var/log/haproxy | + | /var/log/haproxy*.log { |
− | + | daily | |
− | + | missingok | |
− | + | rotate 28 | |
− | + | dateext | |
− | + | compress | |
− | + | delaycompress | |
− | + | notifempty | |
− | + | create 644 www-data adm | |
− | + | sharedscripts | |
− | + | postrotate | |
− | + | /etc/init.d/haproxy reload > /dev/null | |
− | } | + | endscript |
+ | } | ||
4.重启rsyslog和haproxy | 4.重启rsyslog和haproxy |
2013年12月7日 (六) 10:12的最后版本
1. /etc/haproxy/haproxy.cfg开启日志:
global log 127.0.0.1 local0
log 127.0.0.1 local1 notice
defaults配置:
defaults
log global
2. 配置rsyslog: /etc/rsyslog.d/haproxy.conf
if ($programname == 'haproxy') then -/var/log/haproxy.log
3. 配置日志切换: /etc/logrotate.d/haproxy
/var/log/haproxy*.log { daily missingok rotate 28 dateext compress delaycompress notifempty create 644 www-data adm sharedscripts postrotate /etc/init.d/haproxy reload > /dev/null endscript }
4.重启rsyslog和haproxy
sudo restart rsyslog sudo /etc/init.d/haproxy restart