views:

277

answers:

2

Hello,

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 location 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.

A: 

Hi,

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

Ztyx
Any guide to help me how to load a module? and is there a way to log only for files with size more than 10mb?
Shishant
I run command `a2enmod` It gave me choices but `mod_log` was not available in them, then I checked apache.conf it had already some codes that were for CustomLog. I have added the above code to apache.conf restarted it a file got created but nothing was logged.
Shishant
A: 

Deja vu:

http://stackoverflow.com/questions/2371289/how-to-use-apache-logs-to-check-complete-file-downloads

And rtfm 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.

C.

symcbean
I want apache logs because of filesizes, most files are above 300mb which I believe using this method will consume more resources. Can you please help me with the Log format? I pasted it as it in apache2.conf a file get created with the name but nothing is getting logged. Also is it possible to log only for files above 10mb? and Yes I change the format to %X and %O
Shishant