Skip to content

Commit 2c9b4cb

Browse files
authored
Merge pull request #6 from Intellection/log_format_improvements
Log format improvements
2 parents caa3c62 + c2b081f commit 2c9b4cb

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.19.5-4
4+
5+
* Renamed `main` logging format to `main_default`.
6+
* Remove unnecessary double space between `$time_local` & `$status` from
7+
`main_default` logging format.
8+
* Add `main_json` logging format and configure it on `access_log`.
9+
310
## 1.19.5-3
411

512
* Set or forward `X-Request-ID`.

config/log.conf

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
log_format main '$remote_addr - $remote_user [$time_local] $status '
2-
'"$request" $body_bytes_sent "$http_referer" '
3-
'"$http_user_agent" "$http_x_forwarded_for" $proxy_x_request_id';
1+
log_format main_default escape=default
2+
'$remote_addr - $remote_user [$time_local] $status '
3+
'"$request" $body_bytes_sent "$http_referer" '
4+
'"$http_user_agent" "$http_x_forwarded_for" $proxy_x_request_id';
45

5-
access_log /dev/stdout main;
6+
log_format main_json escape=json
7+
'{'
8+
'"body_bytes_sent":"$body_bytes_sent",'
9+
'"host":"$host",'
10+
'"http_referrer":"$http_referer",'
11+
'"http_user_agent":"$http_user_agent",'
12+
'"http_x_forwarded_for":"$http_x_forwarded_for",'
13+
'"proxy_x_forwarded_port":"$proxy_x_forwarded_port",'
14+
'"proxy_x_forwarded_proto":"$proxy_x_forwarded_proto",'
15+
'"proxy_x_forwarded_ssl":"$proxy_x_forwarded_ssl",'
16+
'"proxy_x_request_id":"$proxy_x_request_id",'
17+
'"remote_addr":"$remote_addr",'
18+
'"remote_user":"$remote_user",'
19+
'"request":"$request",'
20+
'"request_length":"$request_length",'
21+
'"request_time":"$request_time",'
22+
'"status": "$status",'
23+
'"time_iso8601":"$time_iso8601"'
24+
'}';
25+
26+
access_log /dev/stdout main_json;
627
error_log /dev/stdout warn;

0 commit comments

Comments
 (0)