You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Montserrat Mateos <mm...@upsa.es> on 2005/11/19 11:50:23 UTC

[users@httpd] log file

Hi, I want configure my access log file for apache and I want that the log
file only save the client request (url) that he write in his navigator and
not other url that the server send as images that the url has.

 

For example: a client in the navigator write 

 

http://172.25.80.46/consulta12b/web/www.embusa.es/index.html

 

And my logfile write

 

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/index.html HTTP/1.1" 200 25477

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwcembassy1.css HTTP/1.1" 200 16307

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwgdepartment_of_state.gif HTTP/1.1" 200
513

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwjflag2.jpg HTTP/1.1" 200 16432

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwgspacer.gif HTTP/1.1" 200 43

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwjsealembassy.jpg HTTP/1.1" 200 3803

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwggrayspacer.gif HTTP/1.1" 200 43

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/titlesp1.jpg HTTP/1.1" 200 5852

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/aid4.jpg HTTP/1.1" 200 25074

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/bilateral/gif/bonorumsfeld050305.jpg
HTTP/1.1" 200 20775

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/irc/gif/zoom_logo.jpg HTTP/1.1" 200 9023

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/irc/gif/logo.gif HTTP/1.1" 200 3569

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwgembassyfootersp.jpg HTTP/1.1" 200
7788

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwglan_graphic.gif HTTP/1.1" 200 44

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/gif/wwwgdottedrule.gif HTTP/1.1" 200 48

 

I’d like that my logfile record only the first line, 

 

172.25.80.46 - - [19/Nov/2005:11:45:14 +0100] "GET
/consulta12b/web/www.embusa.es/index.html HTTP/1.1" 200 25477

 

I have read the documentation about logfiles in apache but I don’t find how
to do with format string of LogFormat. 

 

Is possible configure the access log file to get the thing that I want?

 

Thanks

 

----------------------------------------------------------------------------
-----

Montserrat Mateos Sánchez

 <ma...@upsa.es> mmateossa@upsa.es

Escuela Universitaria de Informática

Universidad Pontificia de Salamanca

C/ Compañia, 5 

37002 - Salamanca 

España

Tfno. +34 923 277100 - Ext 7685

----------------------------------------------------------------------------
-------

 


Re: [users@httpd] log file

Posted by Joshua Slive <js...@gmail.com>.
On 11/19/05, Montserrat Mateos <mm...@upsa.es> wrote:

> Hi, I want configure my access log file for apache and I want that the log
> file only save the client request (url) that he write in his navigator and
> not other url that the server send as images that the url has.

That's not literally possible, and not really a good idea anyway.  
It's not possible because each request looks completely independent
from the server's perspective.  You can look at the referer URL, but
that doesn't guarantee anything.  It's not a good idea because you are
better off recording complete logs and then using a log analysis
program to extract what you need.

But if what you are looking for is just to exclude .gif/.jpg/.css from
your logs entirely, you can do it using something like

SetEnvIf Request_URI \.(?i:gif|jpe?g|css)$ nolog
and then modify your Customlog line to look something like
CustomLog logs/access_log combined env=!nolog

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


Re: [users@httpd] log file

Posted by Sascha Kersken <sk...@lingoworld.de>.
Hello,

----- Original Message ----- 
From: "Montserrat Mateos" <mm...@upsa.es>
To: <us...@httpd.apache.org>
Sent: Saturday, November 19, 2005 11:50 AM
Subject: [users@httpd] log file


> Hi, I want configure my access log file for apache and I want that the log
> file only save the client request (url) that he write in his navigator and
> not other url that the server send as images that the url has.

 The trick is to set an environment variable using SetEnvIf for the file
extensions you want and to append an env=VAR to your CustomLog directive.
The following example only logs requests for files with .htm(l) and .php
endings in NCSA Combined Log Format:

# Set Variable logrequest for HTML and PHP files:
SetEnvIf Request_URI "(\.html?)|(\.php)" logrequest
# Define Combined Log Format (usually predefined in httpd.conf):
LogFormat combined \
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
# Log only if logrequest is set:
CustomLog logs/access_log combined env=logrequest

I would however recommend to leave the access_log file unchanged (logging
ALL requests in it) and define an additional log file for the HTML/PHP
things:

# Default access log file:
CustomLog logs/access_log combined
# Custom log file for HTML/PHP only
CustomLog logs/html_log combined env=logrequest

Hope that helps.

Regards
Sascha


---------------------------------------------------------------------
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