jinnyu opened a new issue, #7352:
URL: https://github.com/apache/apisix/issues/7352
### Current Behavior
`http-logger` lua report error.
### Expected Behavior
Send the request to the configured service correctly
### Error Logs
```
2022/06/29 17:20:13 [error] 49#49: *1586203 failed to run log_by_lua*:
/usr/local/apisix/apisix/utils/log-util.lua:46: attempt to call method 'byte'
(a nil value)
stack traceback:
/usr/local/apisix/apisix/utils/log-util.lua:46: in function
'create_obj_fun'
/usr/local/apisix/apisix/core/lrucache.lua:95: in function
'lru_log_format'
/usr/local/apisix/apisix/utils/log-util.lua:57: in function
'get_custom_format_log'
/usr/local/apisix/apisix/plugins/http-logger.lua:167: in function
'phase_func'
/usr/local/apisix/apisix/plugin.lua:771: in function 'run_plugin'
/usr/local/apisix/apisix/plugin.lua:804: in function
'run_global_rules'
/usr/local/apisix/apisix/init.lua:311: in function 'common_phase'
/usr/local/apisix/apisix/init.lua:710: in function 'http_log_phase'
log_by_lua(nginx.conf:328):2: in main chunk while logging request,
client: 172.17.132.35, server: _, request: "GET /rest/2.0/ocr/v1/idcard
HTTP/1.1", upstream: "https://somehost.com", host: "10.26.20.220:4006"
```
### Steps to Reproduce
1. enable `http-logger` globally
2. plugin config
```
{
"concat_method": "new_line",
"disable": false,
"include_req_body": true,
"include_resp_body": true,
"uri": "report server"
}
```
`log_format` config
```
{
"log_format": {
"streams": [
{
"stream": {
"serviceName": "$service_name",
"routeName": "$route_name",
"host": "$host",
"balancer": "$balancer_ip:$balancer_port"
},
"values": [
[
"$msec",
"{\"ts\":\"$msec\",\"status\":\"$status\",\"request\":{\"ua\":\"$http_user_agent\",\"body-size\":\"$body_bytes_sent\",\"request\":\"$request\"},\"upstream\":{\"addr\":\"$upstream_addr\",\"host\":\"$upstream_host\",\"uri\":\"$upstream_uri\",\"status\":\"$upstream_status\",\"responseTime\":\"$upstream_response_time\"}}"
]
]
}
]
}
}
```
3. do request to apisix
**if enable plugin only, no `log_format` config, plugin can work correctly
with default format,**
**but when `log_format` is configured, an error will be reported**
### Environment
- APISIX version (run `apisix version`): 2.13.0 and 2.14.1
- Operating system (run `uname -a`): offical docker image
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`): 3.14.8
- APISIX Dashboard version, if relevant: 2.13
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]