L
L
lohmag2019-01-23 13:47:13
Nginx
lohmag, 2019-01-23 13:47:13

Nginx and the hierarchy of log directives?

There was a question on nginx, I did not find anything concrete in the docks.
I was very surprised that the access_log directive is not inherited to the downstream server{} and each one must be specified specifically in order for something to be logged. for example

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

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

    access_log  /var/log/nginx/access.log  main;
    include /etc/dockerconf/nginx/conf.d/*.conf;

And from the included file
server {
    listen 80 default_server;

    root /home/www/orion-site/public/;
    access_log  /var/log/nginx/access.log  main; <-- если этого нет, ничего не логируется по нему

    index index.php;

It turns out inheritance of this directive does not work? What about error_log?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2019-01-23
@BorisKorobkov

Inheritance works.
Try
access_log /var/log/nginx/access.log;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question