Nginx log request before processing

loggingnginx

I have nginx server serving a lot of big files. I can see plenty of connections on the server. As it iw know, file to the accesslog is written after the request is completed.

Is there any way to log request before it is served? The problem is that it takes hours to download large files and I would like to know which files were hit.

Best Answer

No this is not natively possible and that would not make much sense too since most logging information requires the request to complete (status code, bytes sent, durations, etc).

But you can still workaround this with the use of a third party scripting module (perl, lua , groovy etc) that would set you free to do whatever you want while the request is being processed.