Home >Operation and Maintenance >Nginx >How to record logs in JSON format in nginx
Define nginx log format:
Copy code The code is as follows:
log_format logstash_json '{ "@timestamp": "$time_local", '
": { '
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"body_bytes_sent": "$body_bytes_sent", '
' "request_time": "$request_time", '
'"status": "$status", '
"request_method": "$request_method" , '
'"http_referrer": "$http_referer", '
'"body_bytes_sent": "$body_bytes_sent", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"http_user_agent ": "$http_user_agent" } }';
The above is the detailed content of How to record logs in JSON format in nginx. For more information, please follow other related articles on the PHP Chinese website!