From b494a3afa43e82694e2b787174b9c43853efc76e Mon Sep 17 00:00:00 2001 From: Andre Pestana <78114138+andrepestana-aot@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:39:07 -0700 Subject: [PATCH] #2305 - Nginx - change configuration to output logs to stdout (#2313) - Configured error_log and access_log to be redirected only to stdout. Kibana should be responsible for capturing the logs output on stdout. Notice that error_log is now configured to "info" log level which means that all the higher [log levels](https://www.keycdn.com/support/nginx-error-log#nginx-error-log-severity-levels) will be also logged. --- sources/packages/web/default.conf.template | 7 +++++++ sources/packages/web/nginx.conf | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sources/packages/web/default.conf.template b/sources/packages/web/default.conf.template index 043f047ed8..59dd6eb0e2 100644 --- a/sources/packages/web/default.conf.template +++ b/sources/packages/web/default.conf.template @@ -1,5 +1,12 @@ # nginx default configuration. + +log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + server { + # Log to stdout + access_log /dev/stdout main; listen ${PORT}; location / { root /opt/app-root/src; diff --git a/sources/packages/web/nginx.conf b/sources/packages/web/nginx.conf index 911f5b937b..8816244bc3 100644 --- a/sources/packages/web/nginx.conf +++ b/sources/packages/web/nginx.conf @@ -1,5 +1,8 @@ worker_processes auto; -error_log /var/log/nginx/error.log warn; + +# Log to stdout +error_log /dev/stdout info; + pid /tmp/nginx.pid; events { worker_connections 1024; @@ -8,10 +11,6 @@ http { include /etc/nginx/mime.types; include /etc/nginx/conf.d/default.conf; default_type application/octet-stream; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; } \ No newline at end of file