0

Is there a way to convert the error.log in Nginx to json? I need to ship the logs to an external log viewer, to do that I need to convert the error.log to json.

Sine C
  • 41
  • 4
  • [`escape=json`](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format) ? – jhnc Aug 27 '20 at 08:37

1 Answers1

0

Using filebeat may be an alternative depending on were you want to ship your logs (see https://www.elastic.co/guide/en/beats/filebeat/current/configuring-output.html)

36ve
  • 513
  • 4
  • 12
  • You're right, sorry ! Were do you want to ship your error logs though ? – 36ve Aug 27 '20 at 09:24
  • I'm shipping them to GCP. But I need to create an internal format so converting it to json will make it easy for me. – Sine C Aug 27 '20 at 10:55
  • Sounds like a proper use case for a filebeat / logstash setup (with filebeat running on the nginx host and sending your logs to a logstash instance/cluster that transforms and ships to GCP using one of the available output plugins) – 36ve Aug 27 '20 at 13:26