This is an automated email from the ASF dual-hosted git repository. membphis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push: new d5dc0e0 doc(http-logger): sync Chinese doc to the English one (#2510) d5dc0e0 is described below commit d5dc0e08d104b877362bd14058af8c47b5f395be Author: 罗泽轩 <spacewander...@gmail.com> AuthorDate: Sun Oct 25 07:54:38 2020 +0800 doc(http-logger): sync Chinese doc to the English one (#2510) --- doc/plugins/http-logger.md | 29 +++++++++++++++++++++++++++++ doc/zh-cn/plugins/http-logger.md | 11 ++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/plugins/http-logger.md b/doc/plugins/http-logger.md index 3fd5b9e..8c4f20b 100644 --- a/doc/plugins/http-logger.md +++ b/doc/plugins/http-logger.md @@ -25,6 +25,7 @@ - [**Attributes**](#attributes) - [**How To Enable**](#how-to-enable) - [**Test Plugin**](#test-plugin) +- [**Metadata**](#metadata) - [**Disable Plugin**](#disable-plugin) @@ -83,6 +84,34 @@ HTTP/1.1 200 OK hello, world ``` +## Metadata + +| Name | Type | Requirement | Default | Valid | Description | +| ---------------- | ------- | ----------- | ------------- | ------- | ---------------------------------------------------------------------------------------- | +| log_format | object | optional | | | Log format declared as JSON object. Only string is supported in the `value` part. If the value starts with `$`, the value is [Nginx variable](http://nginx.org/en/docs/varindex.html). | + + Note that the metadata configuration is applied in global scope, which means it will take effect on all Route or Service which use http-logger plugin. + +### Example + +```shell +curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/http-logger -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "log_format": { + "host": "$host", + "@timestamp": "$time_iso8601", + "client_ip": "$remote_addr" + } +}' +``` + +It is expected to see some logs like that: + +```shell +{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"} +{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"} +``` + ## Disable Plugin Remove the corresponding json configuration in the plugin configuration to disable the `http-logger`. diff --git a/doc/zh-cn/plugins/http-logger.md b/doc/zh-cn/plugins/http-logger.md index 5569432..b45947e 100644 --- a/doc/zh-cn/plugins/http-logger.md +++ b/doc/zh-cn/plugins/http-logger.md @@ -21,11 +21,12 @@ # 目录 -- [**定义**](#name) -- [**属性列表**](#attributes) -- [**如何开启**](#how-to-enable) -- [**测试插件**](#test-plugin) -- [**禁用插件**](#disable-plugin) +- [**定义**](#定义) +- [**属性列表**](#属性列表) +- [**如何开启**](#如何开启) +- [**测试插件**](#测试插件) +- [**插件元数据设置**](#插件元数据设置) +- [**禁用插件**](#禁用插件) ## 定义