Nginx error log settings to write each error only once

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.

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.