P
P
pcdesign2017-01-11 09:53:44
Nginx
pcdesign, 2017-01-11 09:53:44

How to disable logging for urls that contain the word _ajax?

There are different urls like

/some/path/one/_ajax?_=1484114768232
/some/path/two/_ajax
/path/3/_ajax?_=1484114768111
/some/path/two/_ajax/
и т.д.

All of them contain the word "_ajax".
How to turn off logs for all URLs containing it?
Tried like this:
location ~* (_ajax)$ {
                access_log   off;
        }

The logs stop, but at the same time, js scripts that use ajax break.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory, 2017-01-11
@pcdesign

map $request_uri $loggable {
    ~_ajax  0;
    default 1;
}

access_log /path/to/access.log combined if=$loggable;

a similar case is in the documentation, at the end of the description of the access_log directive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question