How to change the log format in nginx?

Change the format of the logs is as follows
 "log_format" piwik '{"ip": "$remote_addr",'
 '"host": "$host",'
 'path: "$request_uri",'
 'status: "$status",'
 '"referrer": "$http_referer",'
 '"user_agent": "$http_user_agent",'
 '"length": $bytes_sent,'
 '"generation_time_milli": $request_time,'
 '"date": "$time_iso8601"}';

 access_log /path/to/log/log_access.piwik log;
 error_log /path/to/log/log_error.piwik log;

But when you restart nginx swears on a wrong config.
July 8th 19 at 12:40
2 answers
July 8th 19 at 12:42
From the error_log you can not change the format.
"log_format" needs to be in http, not the server.
Thank you! - tito commented on July 8th 19 at 12:45
July 8th 19 at 12:44
Move the "log_format" in the context of http

Find more questions by tags NginxLinuxPiwik* nix-like systemsUbuntu