Php – Apache – How to log the file name and size of file uploads

apache-2.2loggingPHPupload

I want to keep some statics about the files uploaded to my server, including the file name, size and response time.

I use PHP to handle the uploads in the server side (client-side is a POST form) but ideally I'd like to use Apache's logging facilities to collect the above-mentioned data. So, I'm trying to modify the default format for the access_log but I only found how to add the response time (using the %D formatter).

Is it possible to use Apache logs to monitor at least the size of POST requests and if possible the filenames of the uploaded files?

Best Answer

As per the Apache documentation you want %I and mod_logio:

%I  Bytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this.
%O  Bytes sent, including headers, cannot be zero. You need to enable mod_logio to use this.