Feature request to "access_log" directive
Francis Daly
francis at daoine.org
Sat Apr 9 06:52:30 UTC 2022
On Mon, Apr 04, 2022 at 04:28:54PM -0300, Fabiano Furtado Pessoa Coelho wrote:
Hi there,
> Sorry to bother you with this feature request. I believe you software
> engineers already thought about it and there are a million reasons to
> not implement it.
I suspect that what you are asking for probably breaks the current nginx
processing and logging model, and would probably require significant
code changes.
You are welcome to submit a patch for it -- after either having written
one, or incentivised someone to write one for you -- and it will
presumably be considered for inclusion in the stock nginx code.
(And if it isn't included in stock, you can always use it in your
version.)
But you may find there is a simpler way to achieve your desired end
result.
> Well, I'm exactly in this situation described here
> https://serverfault.com/questions/498799/how-to-log-nginx-requests-made-to-a-specific-location-in-a-different-file
> I want to use "try_files" and log the access within the location with
> "try_files" directive...
As you probably know, that will do what you say you want if the file
$document_root$uri is present, and not otherwise.
> location /my_system {
> access_log /var/log/nginx/my_system_access.log;
> try_files $uri @named_loc;
> }
> location @named_loc {
> access_log off;
> proxy_pass http://...;
> }
>
> ... and I can't! "Requests are logged in the context of a location
> where processing ends. It may be different from the original location,
> if an internal redirect happens during request processing."
> I can make it work using the "#include" directive and removing the
> named location, but using "try_files" is more clean and sophisticated.
As you say, you can change the config to match what nginx does to what
you want.
Alternatively, you could possibly post-process the log files to end up
with what you want -- either read the old log files and split the contents
according to what you want; or maybe have nginx write to a stream, and
have your own processor reading that stream and writing each log entry
to your desired place for it.
> Is there a way to include the "now" directive to "access_log"?
> Something like: "access_log /var/log/nginx/my_system_access.log now;"
I suspect: only if you provide the code to do so.
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list