The default location is in the container: under /var/log/nginx.
# pwd
/var/log/nginx
# ls -l
total 4
lrwxrwxrwx. 1 root root 11 Dec 2 2021 access.log -> /dev/stdout
lrwxrwxrwx. 1 root root 11 Dec 2 2021 error.log -> /dev/stderr
These two logs are output to the two soft links by default, but there is no log output when viewing these two soft links.
I need to set the log storage location by myself. If the default is not used, the log will be output to the location we set ourselves.
The configuration is as follows:
http {
error_log /var/log/nginx/error2.log;
access_log /var/log/nginx/access2.log;
...
}
or
server {
listen 80;
server_name localhost;
error_log /var/log/nginx/error2.log;
access_log /var/log/nginx/access2.log;
location / {
root html;
index index.html index.htm;
}
}
Restart the container
# ls -l
total 0
lrwxrwxrwx 1 root root 11 Dec 2 2021 access.log -> /dev/stdout
-rw-r--r-- 1 root root 0 Jun 19 07:00 access2.log
lrwxrwxrwx 1 root root 11 Dec 2 2021 error.log -> /dev/stderr
-rw-r--r-- 1 root root 0 Jun 19 07:00 error2.log