16

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?

kenlukas
  • 3,101
  • 2
  • 16
  • 26
mikeb
  • 306
  • 1
  • 4
  • 12

2 Answers2

16

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.

  • not sure how I missed that – mikeb Jun 14 '18 at 12:33
  • Worth to mention: `log_format` only applies to `access_log`. More information, here: https://stackoverflow.com/questions/4246756/is-it-possible-to-specify-custom-error-log-format-on-nginx – ivanleoncz May 22 '20 at 00:08
  • 3
    It would've been helpful to include the definition for log_format combined as that's what I was after. – Gen.Stack Aug 24 '21 at 16:29
10

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"';
Sergei Kozelko
  • 201
  • 2
  • 2