Haproxy在Freebsd下不能记录日志的问题

这几天给蹦心(bengxin.com) 开发环境配置haproxy,遇到的这个问题困扰了我一个晚上,google和baidu了N次也没有找到解决办法,最后自己通读了syslogd和syslog.conf以及haproxy的log相关的man pages,经过若干次的syslogd -d (debug) ,终于在debug日志里面发现了端倪,有这么一个东西导致了日志不能正确的记录到haproxy指定的日志文件里面:

validate: dgram from IP 127.0.0.1, port 49336, name localhost.bengxin.com;
rejected in rule 0 due to port mismatch.
rejected in rule 1 due to port mismatch.
rejected in rule 2 due to port mismatch.

于是给syslogd启动参数加入了下面的内容:

-a 127.0.0.1/32:* -a localhost:* -a 192.168.222.0/16:*

于是乎,期待了很久的haproxy日志出现了!

dev# tail -f /var/log/haproxy/haproxy_3.log
Aug 22 15:32:06 localhost haproxy[64136]: Proxy www started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy cherokee started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy wap started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy pic started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy img started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy public started.
Aug 22 15:32:06 localhost haproxy[64136]: Proxy public started.
Aug 22 15:32:59 localhost haproxy[64137]: 219.142.128.30:6416 [22/Aug/2009:15:32:59.754] public stats/ 0/-1/-1/-1/0 200 17329 – – PR– 0/0/0/0/0 0/0 “GET /?stats HTTP/1.1”
Aug 22 15:32:59 localhost haproxy[64137]: 219.142.128.30:6416 [22/Aug/2009:15:32:59.754] public stats/ 0/-1/-1/-1/0 200 17329 – – PR– 0/0/0/0/0 0/0 “GET /?stats HTTP/1.1”

我的haproxy和日志相关的配置部分如下:



log global
mode http
option httplog
option dontlognull
log 127.0.0.1 local3

还有部分非常关键的东西需要注意,首先是syslog.conf里面必须使用作为分隔符,貌似空格就有问题,然后是需要写成下面的这个格式:

!*
local0.* /var/log/haproxy/haproxy_0.log

最后这一点要感谢bsd社区上的一个老外给我的帮助,回复maillist真是够迅速的!

finally,BS很多国外站点被封,查资料那叫一个不方便!!!!

以上内容,绝对是目前的终极可行的解决方案,查不到第二个!

8 thoughts on “Haproxy在Freebsd下不能记录日志的问题”

  1. I was wondering if you ever thought of changing
    the page layout of your website? Its very well written; I love what youve
    got to say. But maybe you could a little more in the way
    of content so people could connect with it better.
    Youve got an awful lot of text for only having 1 or
    two images. Maybe you could space it out better?

  2. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why waste your intelligence on just posting videos to your site when you could
    be giving us something informative to read?

  3. Write more, thats all I have to say. Literally, it seems as
    though you relied on the video to make your point. You clearly
    know what youre talking about, why throw away your intelligence on just posting videos to your
    site when you could be giving us something informative to read?

  4. Woah! I’m really digging the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between superb usability and visual appeal.
    I must say that you’ve done a excellent job with this. Additionally,
    the blog loads very fast for me on Safari. Outstanding Blog!

  5. Hiya! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a blog article or vice-versa?
    My site goes over a lot of the same subjects as yours and I feel we could greatly benefit from
    each other. If you happen to be interested feel free to
    send me an e-mail. I look forward to hearing from you!
    Awesome blog by the way!

  6. I have been exploring for a bit for any high-quality articles or
    blog posts in this sort of area . Exploring in Yahoo I ultimately stumbled upon this site.
    Reading this info So i’m glad to exhibit that I have a very just right uncanny feeling I discovered exactly what I needed.
    I most surely will make sure to don?t omit this site
    and give it a look on a continuing basis.

  7. An impressive share! I’ve just forwarded this onto a colleague who has been conducting a little homework on this.
    And he in fact ordered me lunch due to the fact that I found it for him…
    lol. So let me reword this…. Thanks for the meal!!
    But yeah, thanks for spending some time to discuss this
    topic here on your web page.

  8. Wow that was strange. I just wrote an very long comment but
    after I clicked submit my comment didn’t appear.
    Grrrr… well I’m not writing all that over again. Anyways, just wanted to say excellent blog!

  9. Hello, Neat post. There is a problem together with your
    web site in web explorer, may check this? IE still is the market chief and a good section of folks will omit your fantastic
    writing because of this problem.

  10. Wow, amazing weblog structure! How lengthy have you ever been running a blog for?
    you made running a blog glance easy. The full glance of your website is great, let alone the
    content material!

  11. great put up, very informative. I wonder why the opposite experts of this sector do not notice this.
    You should proceed your writing. I’m confident, you’ve a great readers’ base already!

  12. Hello, There’s no doubt that your website might be having web browser compatibility issues.
    When I look at your website in Safari, it looks fine
    however when opening in IE, it has some overlapping issues.
    I simply wanted to give you a quick heads up! Aside from that,
    excellent website!

  13. I don’t know if it’s just me or if everyone else encountering problems with your website.
    It seems like some of the written text on your content are running
    off the screen. Can someone else please provide feedback and let
    me know if this is happening to them as well? This could be a
    problem with my web browser because I’ve had this happen before.
    Many thanks

  14. Fantastic blog! Do you have any helpful hints for aspiring writers?

    I’m planning to start my own site soon but I’m a little lost on everything.
    Would you advise starting with a free platform like WordPress or go for a paid option? There are so many
    options out there that I’m completely overwhelmed ..
    Any tips? Bless you!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image