Skip to content

Commit cf6a997

Browse files
committed
Merge pull request #4 from iderdik/enhanced/logging
Add Placeholder to nginx.conf for app name loggging
2 parents 087542f + 6ff2c2e commit cf6a997

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Variable | Example | Description
66
--- | --- | ---
77
`SERVER_MAX_BODY_SIZE` | `SERVER_MAX_BODY_SIZE=4M` | Allows the downstream application to specify a non-default `client_max_body_size` configuration for the `server`-level directive in `/etc/nginx/sites-available/default`
88
`SERVER_INDEX` | `SERVER_INDEX index.html index.html index.php` | Changes the default pages to hit for folder and web roots
9+
`SERVER_APP_NAME` | `APP_NAME='view'` | Sets a kv pair to be consumed by logging service for easy parsing and searching

container/root/run.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ sed -i "s/worker_processes [0-9]\+/worker_processes $(nproc)/" $CONFIG_SERVER
99
sed -i "s/worker_connections [0-9]\+/worker_connections 1024/" $CONFIG_SERVER
1010

1111
echo '[nginx] piping logs to STDOUT'
12-
13-
sed -i "s/access_log [a-z\/\.\;]\+/access_log \/dev\/stdout;/" $CONFIG_SERVER
12+
# Ensure nginx is configured to write logs to STDOUT
13+
# Also set log_format to output SERVER_APP_NAME placeholder
14+
sed -i "s/access_log [a-z\/\.\;]\+/ log_format main \'\$remote_addr - \$remote_user [\$time_local] \"\$request\" \$status \$bytes_sent \"\$http_referer\" \"\$http_user_agent\" SERVER_APP_NAME\';\n access_log \/dev\/stdout main;\n/" $CONFIG_SERVER
1415
sed -i "s/error_log [a-z\/\.\ \;]\+/error_log \/dev\/stdout info;/" $CONFIG_SERVER
1516

1617
if [[ $SERVER_MAX_BODY_SIZE ]]

0 commit comments

Comments
 (0)