2

Is there a way that I can access Apache Log files from my PHP page. Normally the apache will not allow access to outer folders. Is there any alternative way to access log files? If I get those logs I can parse them and find out bandwidth usages

Edit:

I actually want to implement a bandwidth tracking system which can track how much data, a user is downloaded form my site. or uploaded to my site. I searched in stackoverflow and found an answer which suggests parsing log file. I need to automate this so that website itself will parse the log and show the details.any idea?

1
  • Bandwidth tracking should be done by programs specific to it, such as those that are mentioned in Capt.Nemo's system. Your apache log files won't really help determine bandwidth usage as much as they will determine which files are actually being accessed. – Thomas Ward Jan 12 '13 at 0:40
4

I would agree with the other answer and recommend against serving log files via php for apache. Just as a tiny aside, if you are used to php, it can also be run as a scripting language without needing apache. So you can copy your logs and run your php script over them as well.

Since you mentioned bandwidth usage, I would suggest trying out awstats and webalizer for such usage.

4

I would be careful with trying to access the Apache log from anywhere other than local or SSH. Accessing the log files for Apache via PHP or a nonsecure method is not safe, as those logs can contain connection related information in them which if leaked puts users at risk.

I would, if I were you, just download the log file via SFTP or rsync or scp via SSH to your system, and then analyze the logs, rather than try and have PHP serve the log file to you.

-1

I have made very simple php script at

http://malton.duckdns.org/log.php

all you have to do is copy access log to your server root and run php script like the one I made above 1 link ! or track visitors with php which is like this. Ibeleive creating own script is best way to track visitors

http://malton.duckdns.org/ip.php

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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