You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "jinjianming (via GitHub)" <gi...@apache.org> on 2023/05/09 04:27:14 UTC
[GitHub] [apisix] jinjianming opened a new issue, #9440: help request: How to make APISIX output logs in Json format on the terminal
jinjianming opened a new issue, #9440:
URL: https://github.com/apache/apisix/issues/9440
### Description
The default log is
```
10.15.0.159 - [10.15.0.159] - - [09/May/2023:12:25:48 +0800] "POST /serverV1.ServerService/findEnterpriseById HTTP/2.0" 200 282 "-" [-] "grpc-java-netty/1.42.1" 68 0.000 0.004 0.004 10.15.0.178:50000 326 0.004 200 apisix-gateway.ingress-apisix.svc.cluster.local "grpc://apisix-gateway.ingress-apisix.svc.cluster.local:9081"
```
I hope it's in JSON format. How should it be implemented
### Environment
- APISIX version (run `apisix version`): 3.2.0
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- 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: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] shreemaan-abhishek commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1559100636
why would someone need logs on the terminal as opposed to just checking the logs from the error.log file? 🤔
--
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] jinjianming commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "jinjianming (via GitHub)" <gi...@apache.org>.
jinjianming commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1547166817
> maybe you can try this https://apisix.apache.org/docs/apisix/plugins/file-logger/
Thank you for providing the method, but I would prefer the logs output by the terminal to be in JSON format, as I only collect logs from the terminal through other log collection systems;
--
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
Re: [I] help request: How to make APISIX output logs in Json format on the terminal [apisix]
Posted by "jinjianming (via GitHub)" <gi...@apache.org>.
jinjianming commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-2099973943
```
nginx_config: # config for render the template to genarate nginx.conf
error_log: "/usr/local/apisix/logs/error.log"
error_log_level: "warn" # warn,error
worker_processes: "auto"
enable_cpu_affinity: true
worker_rlimit_nofile: 20480 # the number of files a worker process can open, should be larger than worker_connections
event:
worker_connections: 10620
http:
enable_access_log: true
access_log: "/usr/local/apisix/logs/access.log"
access_log_format: '{"content":{"@timestamp": "$time_local", "client_ip": "$remote_addr", "status": "$status", "method": "$request_method", "uri": "$request_uri", "version": "$server_protocol", "body_bytes_sent": "$body_bytes_sent
", "http_referer": "$http_referer", "http_x_register_referrer": "$http_x_register_referrer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "upstream_connect_time": "$upstream_connect_time", "upstream_header_t
ime": "$upstream_header_time", "request_time": "$request_time", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status": "$upstrea
m_status", "host": "$host", "req_id": "$request_id"}}'
# access_log_format: '{"@timestamp": "$time_local", "client_ip": "$remote_addr", "status": "$status", "method": "$request_method", "uri": "$request_uri", "version": "$server_protocol", "body_bytes_sent": "$body_bytes_sent", "http_
referer": "$http_referer", "http_x_register_referrer": "$http_x_register_referrer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "upstream_connect_time": "$upstream_connect_time", "upstream_header_time": "$u
pstream_header_time", "request_time": "$request_time", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status": "$upstream_status"
, "host": "$host", "req_id": "$request_id"}'
access_log_format_escape: json
```
--
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
Re: [I] help request: How to make APISIX output logs in Json format on the terminal [apisix]
Posted by "pavlenkodev (via GitHub)" <gi...@apache.org>.
pavlenkodev commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-2099966313
> > @jinjianming你解决这个问题了吗?
>
> Thank you for your reply. It has been resolved through modification accessLogFormat
>
> ```
> accessLogFormat: |-
> {"@timestamp": "$time_local", "client_ip": "$remote_addr", "status": "$status", "method": "$request_method", "uri": "$request_uri", "version": "$server_protocol", "body_bytes_sent": "$body_bytes_sent", "http_referer": "
> $http_referer", "http_x_register_referrer": "$http_x_register_referrer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "upstream_connect_time": "$upstream_connect_time", "upstream_header_time":
> "$upstream_header_time", "request_time": "$request_time", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status":
> "$upstream_status", "host": "$host", "req_id": "$request_id"}
> # -- Allows setting json or default characters escaping in variables
> accessLogFormatEscape: json
> ```
Hi! I have a similar situation! Tell me, please, where exactly did you enable this setting?
--
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
Re: [I] help request: How to make APISIX output logs in Json format on the terminal [apisix]
Posted by "jinjianming (via GitHub)" <gi...@apache.org>.
jinjianming commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-2099972258
How did you deploy it
--
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] Sn0rt commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1545212508
maybe you can try this https://apisix.apache.org/docs/apisix/plugins/file-logger/
--
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
Re: [I] help request: How to make APISIX output logs in Json format on the terminal [apisix]
Posted by "pavlenkodev (via GitHub)" <gi...@apache.org>.
pavlenkodev commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-2099980954
> How did you deploy it
I use helm for deployment
After your last message with configs, I think I realized what I need to do😊 Thanks! I will try
--
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] jinjianming commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "jinjianming (via GitHub)" <gi...@apache.org>.
jinjianming commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1648996322
> @jinjianming你解决这个问题了吗?
Thank you for your reply. It has been resolved through modification accessLogFormat
```
accessLogFormat: |-
{"@timestamp": "$time_local", "client_ip": "$remote_addr", "status": "$status", "method": "$request_method", "uri": "$request_uri", "version": "$server_protocol", "body_bytes_sent": "$body_bytes_sent", "http_referer": "
$http_referer", "http_x_register_referrer": "$http_x_register_referrer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "upstream_connect_time": "$upstream_connect_time", "upstream_header_time":
"$upstream_header_time", "request_time": "$request_time", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status":
"$upstream_status", "host": "$host", "req_id": "$request_id"}
# -- Allows setting json or default characters escaping in variables
accessLogFormatEscape: json
```
--
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] moonming closed issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "moonming (via GitHub)" <gi...@apache.org>.
moonming closed issue #9440: help request: How to make APISIX output logs in Json format on the terminal
URL: https://github.com/apache/apisix/issues/9440
--
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] Sn0rt commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1647623848
> why would someone need logs on the terminal as opposed to just checking the logs from the error.log file? 🤔
the user can query the field by `jq`I think
--
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] Sn0rt commented on issue #9440: help request: How to make APISIX output logs in Json format on the terminal
Posted by "Sn0rt (via GitHub)" <gi...@apache.org>.
Sn0rt commented on issue #9440:
URL: https://github.com/apache/apisix/issues/9440#issuecomment-1647625073
@jinjianming are you solve this issue ?
--
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