You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/01/11 06:18:25 UTC

[GitHub] [apisix] kerneltravel opened a new issue #6072: docs: add demonstration of log format config of "nginx_config" ?

kerneltravel opened a new issue #6072:
URL: https://github.com/apache/apisix/issues/6072


   ### Improved or typo fixed.
   
   accroding to doc  https://github.com/apache/apisix/blob/master/docs/zh/latest/customize-nginx-configuration.md , I firstly put 
   “nginx_config” inside scope “apisix” of file config/config.yaml ,which many people will do-also but found not work probably in resuting nginx.conf . 
   
   the second (hard) work is the json format log as log-format “main” 
   the third (hard) work is the incident requirement of the above doc, mean 4 space instead of 3space or 2space ,the later two-format space format will make apisix fail to restart.
   
   so here I'd share my fine-tuned demonstration of nginx_config.  for somebody who need an example of this subject.
   
   nginx_config:
     http:
       error_log_level: "info"
       enable_access_log: true
       access_log: logs/access.log
       access_log_format: '{"@timestamp":"$time_iso8601","host":"$hostname","server_ip":"$server_addr","client_ip":"$remote_addr","xff":"$http_x_forwarded_for","domain":"$host","url":"$uri","referer":"$http_referer","args":"$args","upstreamtime":"$upstream_response_time","responsetime":"$request_time","request_method":"$request_method","status":"$status","size":"$body_bytes_sent","request_body":"$request_body","request_length":"$request_length","protocol":"$server_protocol","upstreamhost":"$upstream_addr","file_dir":"$uri","http_user_agent":"$http_user_agent"}'
       access_log_format_escape: json
     http_configuration_snippet: |
       log_format  my-custom-logs-format
       '{"@timestamp":"$time_iso8601",'
       '"host":"$hostname",'
       '"server_ip":"$server_addr",'
       '"client_ip":"$remote_addr",'
       '"xff":"$http_x_forwarded_for",'
       '"domain":"$host",'
       '"url":"$uri",'
       '"referer":"$http_referer",'
       '"args":"$args",'
       '"upstreamtime":"$upstream_response_time",'
       '"responsetime":"$request_time",'
       '"request_method":"$request_method",'
       '"status":"$status",'
       '"size":"$body_bytes_sent",'
       '"request_body":"$request_body",'
       '"request_length":"$request_length",'
       '"protocol":"$server_protocol",'
       '"upstreamhost":"$upstream_addr",'
       '"file_dir":"$uri",'
       '"http_user_agent":"$http_user_agent"'
       '}';
   
   ### Solution
   
   append this content in file config/config.yaml 
   ```
   nginx_config:
     http:
       error_log_level: "info"
       enable_access_log: true
       access_log: logs/access.log
       access_log_format: '{"@timestamp":"$time_iso8601","host":"$hostname","server_ip":"$server_addr","client_ip":"$remote_addr","xff":"$http_x_forwarded_for","domain":"$host","url":"$uri","referer":"$http_referer","args":"$args","upstreamtime":"$upstream_response_time","responsetime":"$request_time","request_method":"$request_method","status":"$status","size":"$body_bytes_sent","request_body":"$request_body","request_length":"$request_length","protocol":"$server_protocol","upstreamhost":"$upstream_addr","file_dir":"$uri","http_user_agent":"$http_user_agent"}'
       access_log_format_escape: json
     http_configuration_snippet: |
       log_format  my-custom-logs-format
       '{"@timestamp":"$time_iso8601",'
       '"host":"$hostname",'
       '"server_ip":"$server_addr",'
       '"client_ip":"$remote_addr",'
       '"xff":"$http_x_forwarded_for",'
       '"domain":"$host",'
       '"url":"$uri",'
       '"referer":"$http_referer",'
       '"args":"$args",'
       '"upstreamtime":"$upstream_response_time",'
       '"responsetime":"$request_time",'
       '"request_method":"$request_method",'
       '"status":"$status",'
       '"size":"$body_bytes_sent",'
       '"request_body":"$request_body",'
       '"request_length":"$request_length",'
       '"protocol":"$server_protocol",'
       '"upstreamhost":"$upstream_addr",'
       '"file_dir":"$uri",'
       '"http_user_agent":"$http_user_agent"'
       '}';
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] juzhiyuan closed issue #6072: docs: add demonstration of log config of "nginx_config" ?

Posted by GitBox <gi...@apache.org>.
juzhiyuan closed issue #6072:
URL: https://github.com/apache/apisix/issues/6072


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] leslie-tsang commented on issue #6072: docs: add demonstration of log config of "nginx_config" ?

Posted by GitBox <gi...@apache.org>.
leslie-tsang commented on issue #6072:
URL: https://github.com/apache/apisix/issues/6072#issuecomment-1015171316


   @juzhiyuan Consider solved. Feel free to reopen it if needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] leslie-tsang commented on issue #6072: docs: add demonstration of log config of "nginx_config" ?

Posted by GitBox <gi...@apache.org>.
leslie-tsang commented on issue #6072:
URL: https://github.com/apache/apisix/issues/6072#issuecomment-1009648831


   Hello there, Thanks for your sharing !
   Would you like to submit a PR to improve the documentation ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org