2

Is there any way to create a custom log file, that allows to see which requests were handled in the same keep-alive session?

I'd like to create some logs and to estimate how often new sessions are created and what typical live times a keep alive session has in some given scenarios.

If possible I wouldn't like to create debug logs for this but just add one item more per log line for each request.

3
  • 1
  • @AlexeyTen thanks a lot. This is the answer. As you sent it as a comment. What do you suggest? I delete the question? You post as answer and I accept? Anything else?
    – gelonida
    Commented May 25, 2020 at 7:40
  • OK true: might do that next time, but prefer to attribute the points to the one who helped me (except the person doesn't care)
    – gelonida
    Commented May 25, 2020 at 14:25

1 Answer 1

3

There are $connection and $connection_requests variables that you could use in custom log_format. Just a sample:

log_format connections '[$time_local] "$request" $connection $connection_requests';

server {
    access_log /var/log/nginx/connections.log connection;
    ...
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .