PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Apache, kompletten Request in LogFile schreiben



pcfreak85
18.02.04, 11:26
Hallo,

Gibt es eine Möglichkeit den kompletten http Request in das Apache Access Log zu schreiben?
Also wenn jemand im Browser eingibt:

"http://www.wurst.de/senf/ketchup.html"

Genau diese Zeile hätte ich gerne im LogFile.
Ich google schon den ganzen Morgen, habe bisher nichts gefunden.

Vielen Dank!

Grüße,

Andreas

Jorge
18.02.04, 12:29
Hast Du Dir schonmal das Apache access.log angesehen?

pcfreak85
18.02.04, 12:37
Da steht nur der Referrer und sonst nix.
ich möchte gerne die komplette URL der aufgerufenen seite haben.
ich hab auch in der Apache Doku nichts gefunden.

Gruß,

Andreas

Jorge
18.02.04, 13:29
Na klar, hab ich doch glatt verwechselt..

Pingu
18.02.04, 13:57
Original geschrieben von pcfreak85
ich hab auch in der Apache Doku nichts gefunden.
Dann schaue nocheinmal genau nach. TIP: http://httpd.apache.org/docs/logs.html#combined

pcfreak85
18.02.04, 15:59
Das ist verdammt nochmal der Referrer!
ich will nicht nur wie in der doku /apache_pb.gif sondern die komplette URL.
So, z.B. http://www.apache.org/pix/4/apache_pb.gif

Und genau das steht eben nicht in der Doku!

Gruß,

Andreas

Pingu
19.02.04, 08:54
Combined Log Format
Another commonly used format string is called the Combined Log Format. It can be used as follows.

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/acces_log combined

This format is exactly the same as the Common Log Format, with the addition of two more fields. Each of the additional fields uses the percent-directive %{header}i, where header can be any HTTP request header. The access log under this format will look like:

127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"


Und von welchem Server das kommt, wirst Du ja wohl wissen. Ansonsten mußt Du halt für jeden VirtualServer eine eigene access.log anlegen. Wenn Du das ganze über die ReWrite-Engine laufen läßt mußt Du sonst dort das LogFile einschalten.

Oder es so machen wie hier

http://httpd.apache.org/docs/logs.html#virtualhosts
For the access log, there is a very good compromise. By adding information on the virtual host to the log format string, it is possible to log all hosts to the same log, and later split the log into individual files. For example, consider the following directives.

LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog logs/access_log comonvhost

The %v is used to log the name of the virtual host that is serving the request. Then a program like split-logfile can be used to post-process the access log in order to split it into one file per virtual host.

Pingu

PS: Bedenke dass z.B. die Domain nicht zum HTTP Request gehört. Denn das was Du im Browser eingibst ist nicht der HTTP Request. Denn ein HTTP Request sieht folgender massen aus (kannst Du auch gerne mit telnet nachvollziehen):


ts@ts-mobile:~
09:49:28 - 501> telnet httpd.apache.org 80
Trying 209.237.227.195...
Connected to minotaur-2.apache.org.
Escape character is '^]'.
GET / HTTP/1.1
HOST: httpd.apache.org

Die zugehörige Antwort wäre:

HTTP/1.1 200 OK
Date: Thu, 19 Feb 2004 08:50:12 GMT
Server: Apache/2.0.48-dev (Unix)
Last-Modified: Thu, 01 Jan 2004 13:48:12 GMT
ETag: "e2ed65-2183-1b3e7f00"
Accept-Ranges: bytes
Content-Length: 8579
Content-Type: text/html; charset=ISO-8859-1

[DATA]

Pingu
19.02.04, 09:15
Original geschrieben von pcfreak85
Das ist verdammt nochmal der Referrer!
ich will nicht nur wie in der doku /apache_pb.gif sondern die komplette URL.
So, z.B. http://www.apache.org/pix/4/apache_pb.gif

Es steht alles in der Doku, z.B. kann man das sich sonst alles auch selber zusammen setzten:

LogFormat "http://%v%U%q" pcfreak85


Pingu