Search code examples
phploggingapache2ubuntu-server

Apache Custom Log Format to track complete file downloads


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.


Solution

  • 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