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 2021/12/21 01:47:09 UTC
[GitHub] [apisix] jagerzhang opened a new issue #5868: docs: Can the Docs show a complete example of log_format?
jagerzhang opened a new issue #5868:
URL: https://github.com/apache/apisix/issues/5868
### Improved or typo fixed.
APISIX有很多日志插件,且支持自定义日志格式,但是文档里面对于自定义日志格式的描述过于简单,加大了自定义日志格式的难度,在搜索引擎搜索相关文档也基本没有log_format的相关说明。
另外,文档里面我看到展示了APISIX可以支持的变量:

感觉应该不止这些,比如 upstream_latency 、apisix_latency 这些阶段耗时字段没找到,有没有地方可以看到所有APISIX支持的可以用于定义log_format的变量呢?
### Solution
总结一下:
1. 建议Docs里面可以展示下默认的log_format,即不配置自定义log_format时输出的日志的格式模板,我们可以快速基于这个模板来自定义log_format,可以简化上手门槛;
2. 除了可以在http://nginx.org/en/docs/varindex.html查看所有Nginx支持的变量,希望也展示下APISIX能支持的所有日志变量;
3. 如果可以的话,建议再展示一些常用的log_format的最佳实践。
--
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] spacewander commented on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-999372053
"upstream_latency 、apisix_latency" those fields are hand-writing. They are not set via variable.
In fact, `log_format` can only support a subset of the data. The default log data can't be represented via log_format.
--
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] jagerzhang edited a comment on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
jagerzhang edited a comment on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-1006265184
> Hi @jagerzhang, here has one PR that describes all Apache APISIX supporting variables, see https://github.com/apache/apisix/pull/5997/files
>
> As for the default `log_format` configuration, we could find them here https://github.com/apache/apisix/blob/master/apisix/plugins/kafka-logger.lua#L90-L95 and https://github.com/apache/apisix/blob/master/apisix/utils/log-util.lua#L33-L40
>
> Could you help to improve the Docs to make it more clear?
谢谢回复,已经看到你们的PR了,辛苦。
其实在不设置log_format元数据的时候,默认的日志格式应该是这样的:https://github.com/apache/apisix/blob/aff5d825aaea12eab312e65e82d060ab9be9b06f/apisix/utils/log-util.lua#L99-L124
所以,我觉得文档中的log_format的例子可以将上述默认日志格式作为展示,比如:
```
{
"url": "$scheme://$host:$server_port$request_uri",
"uri": "$request_uri",
"method": "$request_method",
"headers": "这里是一个集合,可能不太好获取",
"querystring": "$query_string",
"size": "$request_length",
"response": {
"status": "$status",
"headers": "这里是一个集合,可能不太好获取",
"size": "$bytes_sent"
},
"server": {
"hostname": "$hostname",
"version": "$nginx_version"
},
"upstream": "$upstream_addr",
"service_id": "$service_id",
"route_id": "$route_id",
"consumer": "$consumer",
"client_ip": "$client_ip",
"start_time": "$start_time",
"latency": "$latency"
}
```
注:可能有些是一个函数,不知道该怎么改成变量,我大概意思是在不设置log_format的时候的APISIX默认日志格式,可以做成一个一个完整例子,用户在定义log_format的时候只需要参考这个趋向于完整的例子去改,这样上手门槛就降低了非常多了,而且日志也是更全面的。
--
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 commented on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-1006124226
Hi @jagerzhang, here has one PR that describes all Apache APISIX supporting variables, see https://github.com/apache/apisix/pull/5997/files
As for the default `log_format` configuration, we could find them here https://github.com/apache/apisix/blob/master/apisix/plugins/kafka-logger.lua#L90-L95 and https://github.com/apache/apisix/blob/master/apisix/utils/log-util.lua#L33-L40
Could you help to improve the Docs to make it more clear?
--
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] membphis commented on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-999400598
> 总结一下:
>
> 1. 建议Docs里面可以展示下默认的log_format,即不配置自定义log_format时输出的日志的格式模板,我们可以快速基于这个模板来自定义log_format,可以简化上手门槛;
> 2. 除了可以在 http://nginx.org/en/docs/varindex.html 查看所有Nginx支持的变量,希望也展示下APISIX能支持的所有日志变量;
> 3. 如果可以的话,建议再展示一些常用的log_format的最佳实践。
welcome PR, make the doc better
--
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] jagerzhang edited a comment on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
jagerzhang edited a comment on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-1006265184
> Hi @jagerzhang, here has one PR that describes all Apache APISIX supporting variables, see https://github.com/apache/apisix/pull/5997/files
>
> As for the default `log_format` configuration, we could find them here https://github.com/apache/apisix/blob/master/apisix/plugins/kafka-logger.lua#L90-L95 and https://github.com/apache/apisix/blob/master/apisix/utils/log-util.lua#L33-L40
>
> Could you help to improve the Docs to make it more clear?
@juzhiyuan 谢谢回复,已经看到你们的PR了,辛苦。
其实在不设置log_format元数据的时候,默认的日志格式应该是这样的:https://github.com/apache/apisix/blob/aff5d825aaea12eab312e65e82d060ab9be9b06f/apisix/utils/log-util.lua#L99-L124
所以,我觉得文档中的log_format的例子可以将上述默认日志格式作为展示,比如:
```
{
"url": "$scheme://$host:$server_port$request_uri",
"uri": "$request_uri",
"method": "$request_method",
"headers": "这里是一个集合,可能不太好获取",
"querystring": "$query_string",
"size": "$request_length",
"response": {
"status": "$status",
"headers": "这里是一个集合,可能不太好获取",
"size": "$bytes_sent"
},
"server": {
"hostname": "$hostname",
"version": "$nginx_version"
},
"upstream": "$upstream_addr",
"service_id": "$service_id",
"route_id": "$route_id",
"consumer": "$consumer",
"client_ip": "$client_ip",
"start_time": "$start_time",
"latency": "$latency"
}
```
注:可能有些是一个函数,不知道该怎么改成变量,我大概意思是在不设置log_format的时候的APISIX默认日志格式,可以做成一个一个完整例子,用户在定义log_format的时候只需要参考这个趋向于完整的例子去改,这样上手门槛就降低了非常多了,而且日志也是更全面的。
--
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 commented on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-1006267060
Thanks, cc @yzeng25 to have a look 😄 Let's check how to improve our docs.
--
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] jagerzhang closed issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
jagerzhang closed issue #5868:
URL: https://github.com/apache/apisix/issues/5868
--
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] jagerzhang commented on issue #5868: docs: Can the Docs show a complete example of log_format?
Posted by GitBox <gi...@apache.org>.
jagerzhang commented on issue #5868:
URL: https://github.com/apache/apisix/issues/5868#issuecomment-1006265184
> Hi @jagerzhang, here has one PR that describes all Apache APISIX supporting variables, see https://github.com/apache/apisix/pull/5997/files
>
> As for the default `log_format` configuration, we could find them here https://github.com/apache/apisix/blob/master/apisix/plugins/kafka-logger.lua#L90-L95 and https://github.com/apache/apisix/blob/master/apisix/utils/log-util.lua#L33-L40
>
> Could you help to improve the Docs to make it more clear?
谢谢回复,已经看到你们的PR了,辛苦。
其实在不设置log_format元数据的时候,默认的日志格式应该是这样的:https://github.com/apache/apisix/blob/aff5d825aaea12eab312e65e82d060ab9be9b06f/apisix/utils/log-util.lua#L99-L124
所以,我觉得文档中的log_format的例子可以将上述默认日志格式作为展示,比如:
```
{
"url": "$scheme://$host:$server_port$request_uri",
"uri": "$request_uri",
"method": "$request_method",
"headers": "这里是一个集合,可能不太好获取",
"querystring": "$query_string",
"size": "$request_length",
"response": {
"status": "$status",
"headers": "这里是一个集合,可能不太好获取",
"size": "$bytes_sent"
},
"server": {
"hostname": "$hostname",
"version": "$nginx_version"
},
"upstream": "$upstream_addr",
"service_id": "$service_id",
"route_id": "$route_id",
"consumer": "$consumer",
"client_ip": "$client_ip",
"start_time": "$start_time",
"latency": "$latency"
}
```
注:可能有些是一个函数,不知道该怎么改成变量,我大概意思就是log_format在不设置的时候的默认日志格式,可以做成一个例子,用户在定义log_format的时候只需要参考这个趋向于完整的例子去改,这样上手门槛就降低了非常多了,而且日志也是更全面的。
--
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