I have a Nginx service that serves an application. This application sends requests often, because of that, there are a lot of log messages inside my access.log file.
For that reason, I'm trying to create a Conditional Logging to avoid to save these unnecessary log messages.
Based on the documentation, I've tried to create a regex to check if the request contains a substring, but it did not work.
I believe my $request variable should be a request like this one:
GET /catalog-dash/_reload-hash HTTP/1.1
I would like to check if my $request variable contains the _reload-hash substring.
I've created the code below, but it did not work, unfortunately.
map $request $loggable {
~/_reload-hash/ 0;
default 1;
}
access_log /path/to/access.log combined if=$loggable;
If someone could help me, I would appreciate it.
Thank you in advance.
/. The example you give in your question does not. Also, If you are not interested in theGETandHTTP/1.1bits, you could use$request_uriinstead.