motis-project / motis

Intermodal Mobility Information System
https://motis-project.de
MIT License
207 stars 47 forks source link

JSON Logging #221

Open felixguendling opened 2 years ago

felixguendling commented 2 years ago

Example:

{
    "time": "2022-03-08T09:32:20.685+00:00",
    "severity": "WARN",
    "logger": "dispatcher.cc:121",
    "msg": "target not found: /metrics"
}
derhuerst commented 2 years ago

It would be great if the format would follow one of the (many) conventions out there, including the question how to deal with additional fields.

felixguendling commented 2 years ago

I can't find something like a real standard / RFC on JSON logging. Which format would you prefer? There's a lot of content about JSON logging out there but everybody seems to name fields in a different way, have different formats for timestamps, etc.

I think this looks good to me: https://nodejs.org/en/blog/module/service-logging-in-json-with-bunyan/

derhuerst commented 2 years ago

I can't find something like a real standard / RFC on JSON logging.

Yeah, me too. Nothing fully established.

Which format would you prefer?

I like to use pino in the Node.js world, which logs in a format very similar to the well-known bunyan.

I also found the Google Cloud schema.

felixguendling commented 2 years ago

Makes sense. Being compatible to bunyan and/or pino would have the benefit of being able to use their pretty-print tools. Sounds great! :rocket: