开发者

Apache Custom Log Format to track complete file downloads

开发者 https://www.devze.com 2022-12-22 12:38 出处:网络
I am trying to write a reward system wherein users will be given reward points if they download complete files, So what should be my log format.

I am trying to write a reward system wherein users will be given reward points if they download complete files, So what should be my log format.

After searching alot this is what I understand its my first time and havent done custom logs before.

First of all which file should I edit for custom logs because this thing I cant find. I am using ubuntu server with default apache, php5 and mysql installation

# I use this commands and they work fine  
nano /etc/apache2/apache2.conf
/etc/init.d/apache2 restart

I think this is what I need to do for my purpose

LogLevel notice
LogFormat "%f %u %x %o" rewards
CustomLog /var/www/logs/rewards_log rewards

This is as it is command or there is something missing? and is there any particular loc开发者_StackOverflow中文版ation where I need to add this?

and one more thing %o is for filesize that was sent and is it possible to log only files from a particular directory? or for files with size more than 10mb.

Thank You.


Have a look in /etc/apache2/apache2.conf and you should probably be able to find the log directives such as LogLevel and others. Note that those settings are global for your whole Apache installation.

The CustomLog directive can only be set per server/virtual host basis (see scope here).

To use the CustomLog directive you must also load the mod_log module for apache. This can be done with the a2enmod command.

Regards, Jens


Deja vu:

How to use apache logs to check complete file downloads

Check manual for mod_log_config: case is important - that should be %X and %O not %x and %o. %u will only work if you are using basic http authentication (which is a very bad idea) drop a cookie with the (optionally encrypted) username and read it back with %C in your log file if you must take this approach.

A better soluton would be to wrap the file access in a PHP script.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号