logger icon indicating copy to clipboard operation
logger copied to clipboard

Add JSON format strategy

Open jbarbadillo opened this issue 7 years ago • 4 comments

Feature request for a JSON format strategy.

  • Each line is a JSON containing all log properties and values

jbarbadillo avatar Apr 10 '18 13:04 jbarbadillo

I think for log point of view, it might not be that readable. Would you mind to show me an example though?

orhanobut avatar Apr 11 '18 12:04 orhanobut

For readability you already have CSV and pretty logs, but for easy parsing it is a very common solution to use JSON format. In fact there are many tools for parsing JSON logs that allow to filter logs by "field", gather info, etc, like the ELK stack (elasticksearch, logstash, kibana).

I want to implement a JSON handler for myself when I have time, as I need this for a project in which the standard is to use JSON logs with some specific fields, one per line. It is the same Idea as for CSV but each line will be a JSON. I can send you the class when I have time to implement it, just in case you find it useful for the library.

A good example is this library for python structlog.

Also this one serilog.

jbarbadillo avatar Apr 11 '18 17:04 jbarbadillo

👍 I see your point now. That'd be great to have a PR for this, we can discuss over PR and definitely can add it.

orhanobut avatar Apr 12 '18 12:04 orhanobut

As soon as I have time I will implement it, and I will do a pull request. :+1:

I am sure that this feature will make this library more attractive to potential users.

jbarbadillo avatar Apr 12 '18 13:04 jbarbadillo