You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Luc Pardon <lu...@skopos.be> on 2004/10/15 11:09:16 UTC
[RFC] Patch for mod_log_config to allow conditioning on status code
I patched mod_log_config.c (from the 2.0.51 distro) to allow
conditional logging on HTTP status code, like so:
CustomLog king-size.log common status=414
The patch also supports "not" and lists (like the %.. syntax) and
"wildcards", e.g.:
CustomLog ungood.log common status=!20x,3xx
The changes are non-intrusive and the patch is of course backward
compatible.
Rationale: Like everybody else, my servers are increasingly getting
hit with overly long requests. Apache fends them off with a 414, but
those critters are a nuisance in the logs. Sticking "%414r" in the log
format takes care of that, but it also means the request data is lost. I
want to know what's brewing out there so I wanted these request in a
separate log.
It works fine for me and I'd leave it at that, but Googling around
reveals that this might be useful to others.
I already patched the docs and am willing to go the extra mile(s) to
make it all "nice", but the "guidelines for contributing a patch" say
you're a conservative lot when it comes to new functionality.
So, pray tell how I can convince you this is the best thing since
sliced bread ;-)
For a start I'd like to invite comments on a) the concept and b) the
syntax.
If these are acceptable, I would prepare and submit the patch itself
so you can judge the code.
One more thing: I became aware that the "flexible interface for
mod_log_config" patch (# 25014) also allows conditioning on status
code(s), and there are three other contributed patches against
mod_log_config waiting for a decision (# 28037, 29449 and 31311). I am
willing to ensure compatibility with any or all of them if desired.
Thanks for your time,
Luc Pardon
Skopos Consulting
Belgium
RE: [RFC] Patch for mod_log_config to allow conditioning on status code
Posted by "Peter J. Cranstone" <pe...@secure64.com>.
>> Of course. Apache 1.3 is an old, legacy application, and vastly less
>> capable than current versions.
But millions and millions of users rely on it everyday. What might help
migration is a simple chart showcasing the differences between 2.x and 1.x
I'm no power user of Apache but I still can't see why Apache 2.x is a "MUST
HAVE" vs. a stable product in use by millions of users.
Apache is facing a marketing problem not a technology problem
Peter
-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com]
Sent: Saturday, October 16, 2004 6:31 AM
To: dev@httpd.apache.org
Subject: Re: [RFC] Patch for mod_log_config to allow conditioning on status
code
On Sat, 16 Oct 2004, Glenn Strauss wrote:
> I don't want to discourage Luc, but there's a steep uphill battle
> to getting anything into Apache 1.3.
Of course. Apache 1.3 is an old, legacy application, and vastly less
capable than current versions. It's still maintained, but noone is in
the business of adding new *features*.
2.1 is where interesting things happen, while 2.0 is intermediate: new
features may be added, but stability and binary-compatibility are more
important. I might review and incorporate a third-party patch for 2.x,
but certainly wouldn't for 1.x unless someone was paying.
> diff -ruN apache_1.3.31/src/main/http_log.c
apache_1.3.31-new/src/main/http_log.c
> --- apache_1.3.31/src/main/http_log.c 2004-02-16 17:29:33.000000000
-0500
> +++ apache_1.3.31-new/src/main/http_log.c 2004-05-24
12:26:06.000000000 -0400
Bugzilla is a good place for patches like that. People who want it can
help themselves, without compromising stability.
--
Nick Kew
Re: [RFC] Patch for mod_log_config to allow conditioning on status
code
Posted by Nick Kew <ni...@webthing.com>.
On Sat, 16 Oct 2004, Glenn Strauss wrote:
> I don't want to discourage Luc, but there's a steep uphill battle
> to getting anything into Apache 1.3.
Of course. Apache 1.3 is an old, legacy application, and vastly less
capable than current versions. It's still maintained, but noone is in
the business of adding new *features*.
2.1 is where interesting things happen, while 2.0 is intermediate: new
features may be added, but stability and binary-compatibility are more
important. I might review and incorporate a third-party patch for 2.x,
but certainly wouldn't for 1.x unless someone was paying.
> diff -ruN apache_1.3.31/src/main/http_log.c apache_1.3.31-new/src/main/http_log.c
> --- apache_1.3.31/src/main/http_log.c 2004-02-16 17:29:33.000000000 -0500
> +++ apache_1.3.31-new/src/main/http_log.c 2004-05-24 12:26:06.000000000 -0400
Bugzilla is a good place for patches like that. People who want it can
help themselves, without compromising stability.
--
Nick Kew
Re: [RFC] Patch for mod_log_config to allow conditioning on status code
Posted by Glenn Strauss <gs...@gluelogic.com>.
On Fri, Oct 15, 2004 at 08:14:03PM -0600, Paul Querna wrote:
> Glenn Strauss wrote:
> >>On Fri, 15 Oct 2004, Luc Pardon wrote:
> > What are the general requirements to getting a patch or module
> >included in the contrib/ directory? And on that topic, what
> >happened to http://www.apache.org/dist/httpd/contrib/ ?
> >
>
> I think /contrib/ is dead.
>
> I would rather look at committing your patch to httpd CVS.
>
> I don't have any objections to it on a concept level, but I have not
> reviewed your code in detail.
Thanks, Paul.
I don't want to discourage Luc, but there's a steep uphill battle
to getting anything into Apache 1.3. I've tried unsuccessfully
in the past to get what amounts to a two-line addition to
mod_log_config.c to add vhost information to the error log.
Here's some of the history (all for a patch whose meat is 2 lines!):
2003-06-24
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=105649710514527&w=2
2003-07-08
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=105763930020467&w=2
2003-09-04
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=106268054016100&w=2
2003-10-13
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=106608066626342&w=2
http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=106609152403979&w=2
I have been using the current patch, attached below, in production for
a very long time now. Luc, do you think the patch below might have a
place in your modifications, possibly wrapped in an #ifdef so that
it can be enabled or disabled at compile time?
Cheers,
Glenn
#
# http://www.gluelogic.com/code/
#
diff -ruN apache_1.3.31/src/main/http_log.c apache_1.3.31-new/src/main/http_log.c
--- apache_1.3.31/src/main/http_log.c 2004-02-16 17:29:33.000000000 -0500
+++ apache_1.3.31-new/src/main/http_log.c 2004-05-24 12:26:06.000000000 -0400
@@ -349,7 +349,8 @@
* first. -djg
*/
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
- "[client %s] ", r->connection->remote_ip);
+ "[client %s] [%s:%u] ", r->connection->remote_ip,
+ ap_get_server_name(r), ap_get_server_port(r));
}
if (!(level & APLOG_NOERRNO)
&& (save_errno != 0)
Re: [RFC] Patch for mod_log_config to allow conditioning on status
code
Posted by Paul Querna <ch...@force-elite.com>.
Glenn Strauss wrote:
>>On Fri, 15 Oct 2004, Luc Pardon wrote:
> What are the general requirements to getting a patch or module
> included in the contrib/ directory? And on that topic, what
> happened to http://www.apache.org/dist/httpd/contrib/ ?
>
I think /contrib/ is dead.
I would rather look at committing your patch to httpd CVS.
I don't have any objections to it on a concept level, but I have not
reviewed your code in detail.
-Paul Querna
Re: [RFC] Patch for mod_log_config to allow conditioning on status code
Posted by Glenn Strauss <gs...@gluelogic.com>.
On Sat, Oct 16, 2004 at 12:58:48AM +0100, Nick Kew wrote:
> On Fri, 15 Oct 2004, Luc Pardon wrote:
>
> The usual fate of patches in bugzilla is that, even if they are
> appropriate for inclusion, they need a committer to take sufficient
> interest to review and incorporate them. A chronic shortage of round
> tuits means this is rather hit-and-miss.
Quite true and quite the cause of consternation to those of us
lurkers out here eager to help if offered the opportunity ...
> > One more thing: I became aware that the "flexible interface for
> > mod_log_config" patch (# 25014) also allows conditioning on status
> > code(s), and there are three other contributed patches against
> > mod_log_config waiting for a decision (# 28037, 29449 and 31311). I am
> > willing to ensure compatibility with any or all of them if desired.
>
> If you can fix a whole bunch of related bugs on bugzilla without your
> patch becoming big and complex, that adds value but still doesn't
> guarantee anything.
>
> Ask yourself: is your code sufficiently different to anything we already
> have to merit releasing separately as a third-party module? If yes, then
> do that. If no, then it's probably appropriate to offer a patch.
> My guess would be no.
What are the general requirements to getting a patch or module
included in the contrib/ directory? And on that topic, what
happened to http://www.apache.org/dist/httpd/contrib/ ?
Thanks!
Glenn
Re: [RFC] Patch for mod_log_config to allow conditioning on status
code
Posted by Nick Kew <ni...@webthing.com>.
On Fri, 15 Oct 2004, Luc Pardon wrote:
> I patched mod_log_config.c (from the 2.0.51 distro) to allow
> conditional logging on HTTP status code, like so:
>
> CustomLog king-size.log common status=414
>
> The patch also supports "not" and lists (like the %.. syntax) and
> "wildcards", e.g.:
>
> CustomLog ungood.log common status=!20x,3xx
>
> The changes are non-intrusive and the patch is of course backward
> compatible.
Sounds somewhat interesting, and (as you note) there's quite a lot of
demand from people who don't like 414 crap in their logs. So that's
a good start.
But how does it work with piped log programs? If I were implementing
this functionality, I'd probably hack rotatelogs rather than httpd.
> I already patched the docs and am willing to go the extra mile(s) to
> make it all "nice", but the "guidelines for contributing a patch" say
> you're a conservative lot when it comes to new functionality.
Indeed, that's true. But that's very minor functionality and clearly
tied in to an established core module, so unlikely to fall down on that.
The usual fate of patches in bugzilla is that, even if they are
appropriate for inclusion, they need a committer to take sufficient
interest to review and incorporate them. A chronic shortage of round
tuits means this is rather hit-and-miss.
> One more thing: I became aware that the "flexible interface for
> mod_log_config" patch (# 25014) also allows conditioning on status
> code(s), and there are three other contributed patches against
> mod_log_config waiting for a decision (# 28037, 29449 and 31311). I am
> willing to ensure compatibility with any or all of them if desired.
If you can fix a whole bunch of related bugs on bugzilla without your
patch becoming big and complex, that adds value but still doesn't
guarantee anything.
Ask yourself: is your code sufficiently different to anything we already
have to merit releasing separately as a third-party module? If yes, then
do that. If no, then it's probably appropriate to offer a patch.
My guess would be no.
--
Nick Kew
Re: [RFC] Patch for mod_log_config to allow conditioning on status
code
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> For a start I'd like to invite comments on a) the concept and b) the
> syntax.
this sounds interesting in general, although I find myself wondering about a
different approach - expanding SetEnvIf to include response-type things
(like status, content-type, etc) in addition to request-type things.
really, the combination of CustomLog and SetEnvIf should be sufficient for
this kind of thing, provided you can access the needed information from the
request_rec and populate subprocess_env. indeed you could write a simple
log handler of your own that examines r->status and populates
r->subprocess_env accordingly, then still allow mod_log_config to do the
logging with no patch to core required, but I suppose the point here is to
have a way to do this solely from core :)
>
> If these are acceptable, I would prepare and submit the patch itself
> so you can judge the code.
in line with the other suggestions in this thread, I would suggest
submitting a patch against 2.1 (httpd-2.0 cvs HEAD) following the
appropriate style guidelines. I, at least, promise to review it and
shepherd it through the process, wherever that may lead it.
--Geoff