Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'd like to avoid logging some missing files (that gives 404) into error.log. I'm using Apache2.

I want to do this on Eclipse update site for my plugin. Problem is that Eclipse P2 code tries to access its metadata files like content.xml, content.jar, digest.zip and few others, which are not available on my site. When P2 finds this out, it finally reaches for site.xml, which I provide. All in all, everything works fine ... but I have tons of lines like:

[Mon Jul 06 21:46:46 2009] [error] [client 195.91.79.90] File does not exist: ...htdocs/stable/content.jar

in my error.log file, which doesn't help me very much.

One solution that comes to my mind is to let Apache log through grep (via pipe-logging), but I am looking for better solution.

I was thinking about tagging these requests with SetEnvIf directive, and skipping error log for tagged requests, but ErrorLog directive doesn't support that :-(

Any other ideas?

share|improve this question

3 Answers 3

You can do conditional logging using mod_log_config

http://httpd.apache.org/docs/2.0/mod/mod%5Flog%5Fconfig.html

This will allow you to use environment variables.

Example here for not logging image requests.

http://httpd.apache.org/docs/2.0/env.html#examples

share|improve this answer
    
Thank you for answer. I don't mind having these files in access.log. What I want is to get rid of log entries for missing files in ErrorLog. Unfortunately ErrorLog doesn't support conditional logging using environment variables :-( –  Peter Štibraný Jul 7 '09 at 5:01

Wouldn't it have been easier to increase your LogLevel higher than error to warn or crit? Or do you have a reason to keep it lower?

share|improve this answer
    
I am still interested in missing files ... except those few files I know are missing and get lot of hits everyday. –  Peter Štibraný Jul 11 '09 at 12:01
up vote 5 down vote accepted

I found a solution that works for me. I added these lines to .htaccess:

# Don't log missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(artifacts\.jar|content\.xml|content\.jar)$ - [R=404,L]

It uses mod_rewrite. R=404 says to send 404 Not Found status code when client accesses any of mentioned files.

RewriteCode is there to make sure that file indeed doesn't exist. If I ever put one of those files into the directory, it will be served as usual.

This works great: mentioned files are no longer logged into error.log (that was my goal), but are still logged in access log (with 404 status).

share|improve this answer
    
Cool. Sorry, I missed the fact you were after error logging, not access. –  LukeR Jul 9 '09 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.