22

How can I show the current log_format in Nginx?

I do not have it explicitly set (this shows nothing):

grep -i 'log_format' *

And my logging in the config is defined without a format parameter:

access_log /var/log/nginx/access.log;

How can I make Nginx print the value of the current log format, or how can I find out what it is?

2 Answers 2

18

Accoding to: https://nginx.ru/en/docs/http/ngx_http_log_module.html default log format is Combined. If the format is not specified then the predefined “combined” format is used.

3
  • not sure how I missed that
    – mikeb
    Jun 14, 2018 at 12:33
  • Worth to mention: log_format only applies to access_log. More information, here: stackoverflow.com/questions/4246756/…
    – ivanleoncz
    May 22, 2020 at 0:08
  • 5
    It would've been helpful to include the definition for log_format combined as that's what I was after.
    – Gen.Stack
    Aug 24, 2021 at 16:29
15

To expand on Alexander's answer, the definition of the default "combined" log format is given at the end of log_format section. At least for nginx 1.21 it is

log_format combined '$remote_addr - $remote_user [$time_local] '
                '"$request" $status $body_bytes_sent '
                '"$http_referer" "$http_user_agent"';

You must log in to answer this question.

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