Mobile app version of vmapp.org
Login or Join
Gail5422790

: Nginx writing separately to two different logs I've recently taken over as Sysadmin of a site, and the first thing I noticed was that there were two Nginx access_logs defined: access.log and

@Gail5422790

Posted in: #Logging #Nginx #Ubuntu

I've recently taken over as Sysadmin of a site, and the first thing I noticed was that there were two Nginx access_logs defined: access.log and access_new.log, and they were both being written to.

Looking around the configuration I could see that in the http section of nginx.conf it defined access.log as the access_log, and in the sites-enabled/mysite configuration it defined access_new.log as the log. I am curious as to why both of these logs would b written to: surely the configuration for the site would override the default config?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

It is common practice to define a seperate logfile for each vhost. Without knowing your config, I assume, that the main nginx.conf has defined a default log file. It will log any request that is not matching any of the vhosts that might be configured. I assume that sites-enabled/mysite is a vhost that is using name-based virtual host (in Apache speech this is called 'NameVirtualHost'. So every request for this vhost will go into the configured log file for that vhost, any other request, that hits the nginx server (e. g. by calling the IP address instead of the hostname) will (most likely) not match the vhost and therefor will hit the default configuration and it's associated log file.

You might wanna have a look at: nginx.org/en/docs/http/server_names.html and wiki.nginx.org/HttpLogModule

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme