cnhome

cnhome的博客大巴空间
    <<  庆贺一下:) | 首页 | Spring对ApplicationContext的3种实现  >>
  • 2009-04-21

    Apache日志的命名管道输出 - [Linux]

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://cnhome.blogbus.com/logs/38258642.html

    http://www.lovergine.com/2008/01/vlogger-with-named-pipe.html

    可以参考上边的链接去将apache的日志通过命名管道发布给采集程序,而后呢,你就可以做大规模的日志搜集和监控了:)

    In an old post I dealt with the nice mod_chroot module to secure your multisite server. I also adopted recently vlogger in order to manage better apache logs for virtual hosts, when you have dozens or hundreds of them. Unfortunately the suggested way to use it (a simple piped command) does not work nicely with mod_chroot, because the piped command has to run in the chroot jail.

    Of course, it is not a good idea installing the whole perl intepreter and all required modules in a minimized jail, so I adopted an oldish classic trick (the old things are always the best) to solve the issue: using a named pipe. You basically need to do something like the following:

    mkfifo -m 600 /var/run/apache2/logger && chown www-logs /var/run/apache2/logger

    cat /var/run/apache2/logger | /usr/sbin/vlogger -u www-logs -g nogroup -s access.log /var/log/vlogger >/dev/null 2>&1 &

    /etc/init.d/apache2 start


    Of course your log directives will be something like:

    LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vcombined
    CustomLog "/var/run/apache2/logger" vcombined

    You absolutely need to run the reader before the writer, else the init script would hang for ever. It is easy adding a simple init script to run vlogger before apache and it has also the big advantage of not requiring re-fork a perl intepreter at every damn log action. Piping rocks.


    随机文章:

    Spring对ApplicationContext的3种实现 2009-05-04
    详细讲解Java中log4j的使用方法 2009-03-31
    【转】解决在安装EVC4.0+sp4时提示“virtual PC/Windows CE Emulator会造成windows不稳定,windows使这些驱动程序无法加载”的问题 2008-09-28
    【翻译】Oracle Berkeley DB产品族的介绍 2008-09-27
    【转】统计上使用的县以下行政区划代码编制规则 2008-09-27

    收藏到:Del.icio.us




    Tag:
    引用地址:
    cnhome 发表于16:37:17 | 编辑 | 继续话题 | 转发 | 分享 0

搜索

最新日志

  • Infoworld发布2009年度开源软件大奖
  • Spring对ApplicationContext的3种实现
  • Apache日志的命名管道输出
  • 庆贺一下:)
  • 配置Log4j(很详细)
  • 详细讲解Java中log4j的使用方法
  • 用VM6转换VMware ESX Server虚拟机到VMware Server中
  • ActiveMQ Installation Guide
  • 买肉也是有学问地
  • 济南特色之我见(1)
全部日志>>

最新评论

  • zhouwin:收藏.
  • 访问统计:
  • RSS 什么是RSS?
    用IM提醒我内容更新
    订阅到QQ邮箱
    订阅到鲜果阅读器
    订阅到Google阅读器
    订阅到抓虾阅读器
  • 《城客》第四期:创意之城
    博客大巴
    博客大巴使用指南
    博客大巴模板中心
    免费注册博客大巴
    一键博客搬家工具
    中文互动杂志城客
Copyright © 2002-2009 BlogBus.com, All Rights Reserved. 博客大巴 版权所有
博客大巴模板设计: 城·视 | 作者:VCD