+ -
当前位置:首页 → 问答吧 → apache的bug? ----piped log产生乱码。

apache的bug? ----piped log产生乱码。

时间:2010-03-10

来源:互联网

本帖最后由 liangzhishao 于 2010-03-11 10:09 编辑

   首先看看版本号
$ httpd -v
Server version: Apache/2.2.3
Server built:   Jun 12 2007 11:17:57

   下面是httpd.conf的主要配置
  1. ServerLimit 200
  2. ThreadLimit 200
  3. StartServers 100
  4. MaxClients 16000
  5. MinSpareThreads 50
  6. MaxSpareThreads 200
  7. ThreadsPerChild 200
  8. MaxRequestsPerChild 100000
  9. KeepAlive Off


  10. ServerSignature Off
  11. ServerTokens Prod
  12. TraceEnable off
  13. EnableSendfile On
  14. LimitRequestFields 50
  15. #LimitRequestFieldSize 4094
  16. #LimitRequestLine 4094
  17. LogLevel warn
  18. <IfModule log_config_module>
  19.     LogFormat "%h %I %O %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{cookie}i\"" combined

  20.     # liangzhi test 20100302
  21.     #CustomLog "/data/liangzhi/access_log" combined
  22.     #CustomLog "|/home/liangzhi/rotatelog" combined
  23.     #CustomLog "|/usr/local/sbin/cronolog /data/liangzhi/logfile_%Y%m%d%H%M" combined
  24.     #CustomLog "|/data/apache-2.2.3/bin/rotatelogs -l /data/liangzhi/logfile_%Y%m%d%H%M 1200" combined

  25. </IfModule>
复制代码
   
    问题描述
发现在我的服务器上用piped log收集到的access log中有乱码,形如
192.168.168.226 - - [10/Ma192.168.168.226 - - [10/Mar/2010:19:16:23 +0800] "GET /worklog/ HTTP/1.1" 302 1902
r/2010:19:16:23 +0800] "GET /worklog HTTP/1.1" 301 239

而这两条日志应该是
192.168.168.226 - - [10/Mar/2010:19:16:23 +0800] "GET /worklog HTTP/1.1" 301 239
192.168.168.226 - - [10/Mar/2010:19:16:23 +0800] "GET /worklog/ HTTP/1.1" 302 1902
显然是第二行插入到了第一行中间

我还做了大量的测试,总结如下:
1. 用直接写文件和管道两种方式对比,发现数据没有丢,但是管道的数据有乱的,而直接写文件没有乱的
2. 乱码出现的几率是十万分之三左右
3. 乱码都是其中一行被后续的一行或几行切开
4. 混杂在一起的日志都是同一秒内的日志
5. apache 自带的rotatelog 、官方推荐的cronolog以及我自己用c写的各种filter程序都不能避免这个问题


   希望遇到同样问题的坛友能一起讨论讨论,最好解决此问题,解决不了也一起学习一下,哈哈

作者: liangzhishao   发布时间: 2010-03-10

观察

作者: scyzxp   发布时间: 2010-03-10

关注

你修改过log的配置代码么?

作者: ruochen   发布时间: 2010-03-13