If I enable access and error logs in /etc/nginx/nginx.conf:
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
Should I also be keeping logs in server blocks like:
server {
listen 80;
server_name www.somesite.org;
root /var/www/somesite/;
access_log /var/log/nginx/somesite.org.access.log;
error_log /var/log/nginx/somesite.org.error.log;
}
Or this is redundant assuming that everything that’s in “somesite” specific logs is already captured by master logs defined in nginx.conf?
I do have several virtual hosts though and I am wondering if above is true, would it be a better practice to disable logging in nginx.conf and log in individual server blocks so that I can keep domain name specific logs nice and clean?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This comment has been deleted
If you have several virtual hosts, it’s generally good practice to separate the log files by defining site specific logs in your server block. Though it’s really just a matter of preference and readability. So it’s up to you.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.