|Problems? Is your data what you think it is?|
Merged lines with Apache::LogFile-based log handlerby bronto (Priest)
|on Jul 09, 2007 at 15:24 UTC||Need Help??|
bronto has asked for the
wisdom of the Perl Monks concerning the following question:
I built a small mod_perl handler that logs a message in a custom log file depending on the presence and the value of an HTTP header. It is named Tiscali::LogLoadBalancer and uses the Apache::LogFile module this way in httpd.conf:
The handler works almost well: header's values are correctly logged into the logs/loadbalancer.log file. E.g.:Mon Jul 9 16:53:56 2007  X-Loadbalancer: 0 (OK)
Unfortunately, when the server is heavily stressed (like launching three parallel instances of the ab utility with three different values for that header) it happens quite often that two (or more!) different log messages are merged togehter, e.g.:Mon Jul 9 16:53:56 2007  X-Loadbalancer: 2 (INVALID)Mon Jul 9 16:53:56 2007  X-Loadbalancer: 1 (OK)
Is there any way to avoid that side effect? When I opted for an Apache::LogFile-based solution I did it also because I believed that this kind of issue was already taken care of by the author, who has a well respected name in the community. I guess I am probably doing something wrong, but I can't tell what... any help?
Module's code follows:
In theory, there is no difference between theory and practice. In practice, there is.