Nginx error log settings to write each error only once

August 26, 2016 1.6k views
Nginx Logging Ubuntu 16.04

Hello everyone,

Is there any settings I can use to tell nginx to write same error only once in log file.

I have a high traffic site and when there is an error. because the same error is written for each request. the log file size gets too large too quickly.

Thanks for your advise.

1 Answer

I am not aware of any way to do this. While it would be possible to disable error logs completely I don’t know of any native way to filter them like this. I can also see this causing potential issues. If you were able to set this up, while you would no longer be flooded with error messages, how would you know an error that occurred previously was fixed if your web server stopped reporting it after it occurred once? How would you know if an issue in your logs was a one-off instance or endemic and affecting all your users? There are solutions for log analysis (feeding your logs into another system to process them) or rotation (to prevent ending up with massive log files to dig through) that might be a better fit.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!