You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Robert Andersson <ro...@profundis.nu> on 2003/10/31 13:42:31 UTC

[users@httpd] Avoid logging errors successfully handled by ErrorDocument

Hello,

I'm using a system where images in a special directory are automatically
created when first requested. I do this by setting ErrorDocument 404 to
script that creates the image and deliver it with a 200 status code.

However, these requests still results in a line in the error log, which is
annoying (it grows as fast as the access log). In the access log, they will
have a 200 status code. I've been thinking about it, as well as searched
around but been unable to come up with how to avoid these request being
logged. A

On a related note, is there any way to "pass back" an error, eg. File Not
Found, to Apache from a dynamic ErrorDocument? This would be useful when
using an ErrorDocument in order to try to fix the error, and when unable to,
let Apache deal with it as the ErrorDocument didn't exist. Could this be
achieved in some way?

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Avoid logging errors successfully handled by ErrorDocument

Posted by Robert Andersson <ro...@profundis.nu>.
Joshua Slive wrote:
> The contents of the error log are not configurable (except via the
> LogLevel directive).  One possible solution would be to use mod_rewrite
> rather than an ErrorDocument.  See, for example, "Search pages in more
> than one directory":
> http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
> which does something similar.

Yes, that worked. Previously I had something like this:

    ErrorDocument 404 /.../_lib/gallery/img_cachemiss.php?max_width=2048

I now substituted the error document with these lines in an .htaccess:

    RewriteCond %{REQUEST_FILENAME}  !-f
    RewriteRule .* /.../_lib/gallery/img_cachemiss.php?max_width=2048 \
        [env=GALLERY_CACHEMISS:1]

I had a check in that script (img_cachemiss.php), which would only let it
execute if REDIRECT_STATUS was 404. The only way I could ensure it not to be
executed directly was to add a check for that environment variable.

A note here: I was a bit surprised that this worked, because I exploit
multiviews here, so the images are requested without their file extensions.
I'd have thought that the RewriteCond would kick in on a request for eg.
"image" when the existing file is "image.jpeg". It seems as mod_negotiation
do the translation before mod_rewrite does its thing.

However, I will probably use the ErrorDocument variant most of the time, and
survive the occasional 404s in the error log, as it is a simpler and less
error prone

> > On a related note, is there any way to "pass back" an error, eg. File
Not
> > Found, to Apache from a dynamic ErrorDocument? ... Could this be
> > achieved in some way?
>
> Not that I know of.

I didn't think so either. Thanks anyway.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Avoid logging errors successfully handled by ErrorDocument

Posted by Joshua Slive <jo...@slive.ca>.
On Fri, 31 Oct 2003, Robert Andersson wrote:
> I'm using a system where images in a special directory are automatically
> created when first requested. I do this by setting ErrorDocument 404 to
> script that creates the image and deliver it with a 200 status code.
>
> However, these requests still results in a line in the error log, which is
> annoying (it grows as fast as the access log). In the access log, they will
> have a 200 status code. I've been thinking about it, as well as searched
> around but been unable to come up with how to avoid these request being
> logged. A

The contents of the error log are not configurable (except via the
LogLevel directive).  One possible solution would be to use mod_rewrite
rather than an ErrorDocument.  See, for example, "Search pages in more
than one directory":
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
which does something similar.

> On a related note, is there any way to "pass back" an error, eg. File Not
> Found, to Apache from a dynamic ErrorDocument? This would be useful when
> using an ErrorDocument in order to try to fix the error, and when unable to,
> let Apache deal with it as the ErrorDocument didn't exist. Could this be
> achieved in some way?

Not that I know of.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org