This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new dae6c78  feat: add accesslog and errorlog (#190)
dae6c78 is described below

commit dae6c78b17c119fa8dfd553f59e015bc7a7add44
Author: Gallardot <[email protected]>
AuthorDate: Thu Dec 9 17:08:39 2021 +0800

    feat: add accesslog and errorlog (#190)
---
 charts/apisix/README.md                | 10 ++++++++++
 charts/apisix/templates/configmap.yaml | 11 ++++++++---
 charts/apisix/values.yaml              |  9 +++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index 427bfc0..16c550a 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -176,6 +176,16 @@ discovery:
         read: 5000
 ```
 
+### logs parameters
+
+| Parameter                       | Description                                
                                                                                
                                                         | Default    |
+|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|
+| `logs.enableAccessLog`                  | Enable access log or not, default 
true | `true` |
+| `logs.accessLog`                  | Access log path | `/dev/stdout` |
+| `logs.accessLogFormat`                  | Access log format | `$remote_addr 
- $remote_user [$time_local] $http_host \"$request\" $status $body_bytes_sent 
$request_time \"$http_referer\" \"$http_user_agent\" $upstream_addr 
$upstream_status $upstream_response_time 
\"$upstream_scheme://$upstream_host$upstream_uri\"` |
+| `logs.accessLogFormatEscape`                  | Allows setting json or 
default characters escaping in variables | `default` |
+| `logs.errorLog`                  | Error log path | `/dev/stderr` |
+| `logs.errorLogLevel`                  | Error log level | `warn` |
 
 ### dashboard parameters
 
diff --git a/charts/apisix/templates/configmap.yaml 
b/charts/apisix/templates/configmap.yaml
index 2c5657a..3ee538d 100644
--- a/charts/apisix/templates/configmap.yaml
+++ b/charts/apisix/templates/configmap.yaml
@@ -144,13 +144,18 @@ data:
         {{- end }}
 
     nginx_config:                     # config for render the template to 
genarate nginx.conf
-      error_log: "/dev/stderr"
-      error_log_level: "warn"         # warn,error
+      error_log: "{{ .Values.logs.errorLog }}"
+      error_log_level: "{{ .Values.logs.errorLogLevel }}"         # warn,error
       worker_rlimit_nofile: 20480     # the number of files a worker process 
can open, should be larger than worker_connections
       event:
         worker_connections: 10620
       http:
-        access_log: "/dev/stdout"
+        enable_access_log: {{ .Values.logs.enableAccessLog }}
+        {{- if .Values.logs.enableAccessLog }}
+        access_log: "{{ .Values.logs.accessLog }}"
+        access_log_format: "{{ .Values.logs.accessLogFormat }}"
+        access_log_format_escape: {{ .Values.logs.accessLogFormatEscape }}
+        {{- end }}
         keepalive_timeout: 60s         # timeout during which a keep-alive 
client connection will stay open on the server side.
         client_header_timeout: 60s     # timeout for reading client request 
header, then 408 (Request Time-out) error is returned to the client
         client_body_timeout: 60s       # timeout for reading client request 
body, then 408 (Request Time-out) error is returned to the client
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index c30d6c9..ccbaa0b 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -237,6 +237,15 @@ discovery:
       #     send: 2000
       #     read: 5000
 
+# access log and error log configuration
+logs:
+  enableAccessLog: true
+  accessLog: "/dev/stdout"
+  accessLogFormat: '$remote_addr - $remote_user [$time_local] $http_host 
\"$request\" $status $body_bytes_sent $request_time \"$http_referer\" 
\"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time 
\"$upstream_scheme://$upstream_host$upstream_uri\"'
+  accessLogFormatEscape: default
+  errorLog: "/dev/stderr"
+  errorLogLevel: "warn"
+
 dns:
   resolvers:
     - 127.0.0.1

Reply via email to