Apache Log files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nunners
Forum Commoner
Posts: 89
Joined: Tue Jan 28, 2003 7:52 am
Location: Worcester, UK
Contact:

Apache Log files

Post by Nunners »

I'm trying to create my own log files, equivalent to the Apache ones using PHP.

I need to create the format:
62.161.78.75 - - [dd/mmm/yyyy:hh:mm:ss +0000] "GET / HTTP/1.1" 200 1234 "http://www.from.com/from.html" "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
So far I've got this:

Code: Select all

echo($_SERVERї"REMOTE_ADDR"]." - - ї".DATE("d/M/Y:h:m:s +O")."] "".$_SERVERї"REQUEST_METHOD"]." / ".$_SERVERї"SERVER_PROTOCOL"]."" 200 1234 "http://".$_SERVERї"SERVER_NAME"]."".$_SERVERї"SCRIPT_NAME"]."" "".$_ENVї"HTTP_USER_AGENT"].""");
The only two values I'm missing are 200 (the Status Code) and 1234 (the size of the object returned to the client). Is there anyway of getting these variables from PHP? Please help!

Thanks
Nunners
Post Reply