View Full Version : [ubuntu] access.log blocked - can I generate one with php?
swharden
January 14th, 2009, 03:37 PM
I have a PHP-enabled website that's hosted professionally, but they don't give me access to my logfiles. Is there an easy way to use PHP to generate my own "access.log", so that I can analyze it myself with stats programs (like awstats)?
Thanks!! --Scott
swharden
January 20th, 2009, 01:23 PM
anyone?
drubin
January 20th, 2009, 02:04 PM
not with out writing your own logging into your php scripts. But this would have to appear in a globally included file so that it is on every page.
Also lots of files writing to the same logfile. opening and closing it might be a bit load intensive.
Apache keeps the logfile open and has correct threading to handle this.
Have you tried google analytics (https://www.google.com/analytics/)? It provides and online logging facility with graphs and charts.
swharden
January 22nd, 2009, 04:56 PM
Have you tried google analytics (https://www.google.com/analytics/)? It provides and online logging facility with graphs and charts.
Yes, but I want to see IP addresses and match them with requests (which is against Google's privacy policy)
SOLUTION: It's not amazing, but it works. http://www.swharden.com/blog/2009-01-22-using-php-to-create-apache-style-accesslog/
drubin
January 23rd, 2009, 05:04 AM
Yes, but I want to see IP addresses and match them with requests (which is against Google's privacy policy)
SOLUTION: It's not amazing, but it works. http://www.swharden.com/blog/2009-01-22-using-php-to-create-apache-style-accesslog/
for highload/traffic servers that is going to cause a dead lock with all the file locks at the same time. For simple none highloads it will be fine :)
Only issue is that it doesn't log image/css/javascript...* requests since they aren't php files. It might also interfere with your php CLI scripts since it was configed in php.ini and not apache.
swharden
January 23rd, 2009, 11:42 AM
for highload/traffic servers that is going to cause a dead lock with all the file locks at the same time. For simple none highloads it will be fine :)
Only issue is that it doesn't log image/css/javascript...* requests since they aren't php files. It might also interfere with your php CLI scripts since it was configed in php.ini and not apache.
I can't think of a better option. Can you? I'd love to have apache give me log files, but since my webhost doesn't give me that option, I'm kind of stuck. There isn't *ANY* way I could log file access anyway given my situation, right?
An alternative to file opening/closing would be to use a SQL database... perhaps it'd be more load-friendly.
drubin
January 25th, 2009, 03:19 PM
I can't think of a better option. Can you? I'd love to have apache give me log files, but since my webhost doesn't give me that option, I'm kind of stuck. There isn't *ANY* way I could log file access anyway given my situation, right?
An alternative to file opening/closing would be to use a SQL database... perhaps it'd be more load-friendly.
How highload are these sites? If they do not get an excessive high traffic then don't worry to much about it. I just mentioned it as it is a point to take note of for higher pageviewed sites (Also this doesn't log images/files).
The db option is a pretty nice one since the DB would handle the thread syncronisation but you would have to build custom reporting = mission unless it is needed.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.