1.https://github.com/jiaz/nginx-http-json-log#how-to-build,
2.https://github.com/lindsayevans/nginx-json-status-module
I added these two modules and followed the instructions.But I am still getting plain text logs.
Any idea for other solutions to log in JSON format from nginx or any changes in above two solutions?
Please paste your nginx.conf file also.
here it is what you want.
worker_processes 4;
events {
worker_connections 102400;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format post_json escape=json $request_body;
server {
listen 8080;
server_name localhost;
location /log_json {
return 200;
}
location / {
if ($request_method != POST) {
return 404;
}
access_log /usr/local/var/log/nginx/log_json.log post_json;
proxy_pass $scheme://127.0.0.1:$server_port/log_json;
}
}
include servers/*;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.