Hi, Francis. Thanks for the reply.
I'm gonna try to implement this feature, but I think it will be hard for me. For now, I'll change the NGINX configuration files to use access_log according to my needs. I've one more question about an access_log weird behavior, when it's configured with a $1 regex return variable. For instance: location ~ ^/(system1|system2) { access_log /var/log/nginx/$1_access.log; proxy_pass ...; } The only way NGINX can write to system1_access.log and system2_access.log files is when they exist in the specified directory. Otherwise, the log isn't computed. I think creating them at the moment of system start is impossible because the $1 variable isn't initialized yet, but why can't NGINX automatically create them at the moment they are used? Thanks again. Fabiano On Sat, Apr 9, 2022 at 3:55 AM Francis Daly wrote: > > 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 fran...@daoine.org > _______________________________________________ > nginx mailing list -- nginx@nginx.org > To unsubscribe send an email to nginx-le...@nginx.org _______________________________________________ nginx mailing list -- nginx@nginx.org To unsubscribe send an email to nginx-le...@nginx.org