-
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【翻译】Oracle Berkeley DB产品族的介绍 2008-09-27【转】统计上使用的县以下行政区划代码编制规则 2008-09-27
收藏到:Del.icio.us







