Nginx writing separately to two different logs
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: http://nginx.org/en/docs/http/server_names.html and http://wiki.nginx.org/HttpLogModule
Related videos on Youtube
benwad
Updated on September 18, 2022Comments
-
benwad over 1 year
I've recently taken over as Sysadmin of a site, and the first thing I noticed was that there were two Nginx
access_log
s defined:access.log
andaccess_new.log
, and they were both being written to.Looking around the configuration I could see that in the
http
section ofnginx.conf
it definedaccess.log
as theaccess_log
, and in thesites-enabled/mysite
configuration it definedaccess_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?