From 96db3a450d9fcfbf485f007bc7f79c8c99a07c05 Mon Sep 17 00:00:00 2001 From: florian Date: Tue, 18 May 2021 21:51:13 +0200 Subject: [PATCH] log - add LOG_LEVEL variable --- confs/global/nginx.conf | 2 +- confs/site/log-lua.conf | 2 +- docs/environment_variables.md | 6 ++++++ entrypoint/defaults.sh | 1 + entrypoint/global-config.sh | 3 ++- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/confs/global/nginx.conf b/confs/global/nginx.conf index 2ba2432..d8e59a0 100644 --- a/confs/global/nginx.conf +++ b/confs/global/nginx.conf @@ -53,7 +53,7 @@ http { # write logs to local syslog log_format logf '%LOG_FORMAT%'; access_log /var/log/access.log logf; - error_log /var/log/error.log info; + error_log /var/log/error.log %LOG_LEVEL%; # temp paths proxy_temp_path /tmp/proxy_temp; diff --git a/confs/site/log-lua.conf b/confs/site/log-lua.conf index cd77739..4ed4a7d 100644 --- a/confs/site/log-lua.conf +++ b/confs/site/log-lua.conf @@ -9,7 +9,7 @@ local bad_behavior_count_time = %BAD_BEHAVIOR_COUNT_TIME% local bad_behavior_ban_time = %BAD_BEHAVIOR_BAN_TIME% if use_bad_behavior then - behavior.count(bad_behavior_status_code, bad_behavior_threshold, bad_behavior_count_time, bad_behavior_ban_time) + behavior.count(bad_behavior_status_codes, bad_behavior_threshold, bad_behavior_count_time, bad_behavior_ban_time) end } diff --git a/docs/environment_variables.md b/docs/environment_variables.md index 3151925..9f95a1d 100644 --- a/docs/environment_variables.md +++ b/docs/environment_variables.md @@ -69,6 +69,12 @@ Default value : *$host $remote_addr - $remote_user \[$time_local\] "$request" $s Context : *global* The log format used by nginx to generate logs. More info [here](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format). +`LOG_LEVEL` +Values : *debug, info, notice, warn, error, crit, alert, or emerg* +Default value : *info* +Context : *global* +The level of logging : *debug* means more logs and *emerg* means less logs. More info [here](https://nginx.org/en/docs/ngx_core_module.html#error_log). + `HTTP_PORT` Values : *\* Default value : *8080* diff --git a/entrypoint/defaults.sh b/entrypoint/defaults.sh index 114eea0..8ca5e19 100644 --- a/entrypoint/defaults.sh +++ b/entrypoint/defaults.sh @@ -2,6 +2,7 @@ MULTISITE="${MULTISITE-no}" LOG_FORMAT="${LOG_FORMAT-\$host \$remote_addr - \$remote_user [\$time_local] \"\$request\" \$status \$body_bytes_sent \"\$http_referer\" \"\$http_user_agent\"}" +LOG_LEVEL="${LOG_LEVEL-info}" HTTP_PORT="${HTTP_PORT-8080}" HTTPS_PORT="${HTTPS_PORT-8443}" MAX_CLIENT_SIZE="${MAX_CLIENT_SIZE-10m}" diff --git a/entrypoint/global-config.sh b/entrypoint/global-config.sh index 68fea84..89a1b90 100644 --- a/entrypoint/global-config.sh +++ b/entrypoint/global-config.sh @@ -66,8 +66,9 @@ else replace_in_file "/etc/nginx/nginx.conf" "%MULTISITE_DEFAULT_SERVER%" "" fi -# custom log format +# logging replace_in_file "/etc/nginx/nginx.conf" "%LOG_FORMAT%" "$LOG_FORMAT" +replace_in_file "/etc/nginx/nginx.conf" "%LOG_LEVEL%" "$LOG_LEVEL" # proxy_cache zone if [ "$(has_value USE_PROXY_CACHE yes)" != "" ] ; then