码迷,mamicode.com
首页 > 其他好文 > 详细

haproxy配置日志及自定义日志

时间:2017-03-28 14:37:08      阅读:574      评论:0      收藏:0      [点我收藏+]

标签:日志   haproxy   

日志级别:

    emerg 0 系统不可用
    alert 1 必须马上采取行动的事件
    crit 2 关键的事件
    err 3 错误事件
    warning 4 警告事件
    notice 5 普通但重要的事件
    info 6 有用的信息
    debug 7 调试信息

配置记录日志:

    在默认情况haproxy是不记录日志的;

    通过配置haproxy.cfg使其记录日志

    haproxy.cfg:开启haproxy日志记录

        log 127.0.0.1 local2
    /etc/rsyslog.conf:利用rsyslog接收日志:

        去掉这两行的注释:
            $ModLoad imudp    
            $UDPServerRun 514
        新增这一行:
            local2.* /var/log/haproxy.log

    重启rsyslog,查看udp的514端口是否开启:

        #/etc/init.d/rsyslog restart

        #netstat -tunpl

配置haproxy记录更详细的日志:

    默认的日志可读性很差,我们需要显示更多的信息,但默认的都捕获不到,只能自定义需要显示的内容了

    capture request header Host len 64
    capture request header User-Agent len 128
    capture request header X-Forwarded-For len 100
    capture request header Referer len 200
    capture response header Server len 40
    capture response header Server-ID len 40
    log-format %ci:%cp\ %si:%sp\ %B\ %U\ %ST\ %r\ %b\ %f\ %bi\ %hrl\ %hsl\

    重启haproxy即可

本文出自 “激情燃烧的岁月” 博客,请务必保留此出处http://liuzhengwei521.blog.51cto.com/4855442/1910986

haproxy配置日志及自定义日志

标签:日志   haproxy   

原文地址:http://liuzhengwei521.blog.51cto.com/4855442/1910986

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!