How to write access logs to /var/logs/nginx/access.log instead of stdout? #4341
-
How to make the Nginx ingress controller to write logs to log file instead of stdout?
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
Hi @noor-muradi It's currently only possible to toggle on/off access logging using a ConfigMap. You will have to use custom-templates in order to overwrite the log output directory that we set for access_log For NGINX OSS the output directory for access_logs are set here: For NGINX Plus, it's set here: If anything is unclear on how this works, please let me know! |
Beta Was this translation helpful? Give feedback.
-
Just adding another data point to this. I have a customer who would like the ability to configure a different destination for access_log. They are existing NGINX App Protect customers, and have configured NAP to send the logs to an external syslog server. They would like for NGINX Ingress Controller to have similar capability to standardize how logs are streamed. They are currently modifying the Virtual Server template to set a custom access_log destination as a workaround, but that is not ideal as they have to update the template each time NGINX Ingress Controller gets updated. |
Beta Was this translation helpful? Give feedback.
-
hi @noor-muradi, we're looking at this proposal and figuring out what's the best way to design such solution. Will keep you updated here 👍🏼 |
Beta Was this translation helpful? Give feedback.
-
Hi @noor-muradi, because of how quickly the volumes can get filled with access-logs, we're a bit apprehensive of making this a default capability in NIC. Still investigating |
Beta Was this translation helpful? Give feedback.
-
Waiting 2 years, closing. |
Beta Was this translation helpful? Give feedback.
NGINX Ingress Controller outputs to stdout following K8s convention. So that the NIC logs are captured and associated with the pods. This is normal K8s practice.
NGINX (the proxy used under the hood) can send event or access logs direct to syslog sink. This would be an override of the NIC templates and at this point require modifying the templates and building the image, or the use of a custom image.
That said, there are customers that direct NGINX logs to file (Access log most commonly). And the warning we give there is around volume filling which results in the pod being killed. Because log rotation cron jobs do not run within containers.