quarkiverse / quarkus-logging-json

Quarkus logging extension outputting the logging in json.
Apache License 2.0
62 stars 29 forks source link

google cloud platform format #177

Open msillence opened 2 years ago

msillence commented 2 years ago

It would be great to have a GCP format https://cloud.google.com/logging/docs/structured-logging Log4j2 has some support the mappings are documented: https://logging.apache.org/log4j/2.x/manual/json-template-layout.html sepecifically they say:

GcpLayout.json described by Google Cloud Platform structured logging with additional _thread, _logger and _exception fields. The exception trace, if any, is written to the _exception field as well as the message field – the former is useful for explicitly searching/analyzing structured exception information, while the latter is Google’s expected place for the exception, and integrates with Google Error Reporting.

it would be great if this was somewhat compatible a sample message from log4j2 in GcpLayout:

{
    "timestamp": "2022-05-06T15:11:13.059Z",
    "severity": "ERROR",
    "message": "error abc due to:\nabc.def.ghi.MyException: problem specifics.\nMore details ...",
    "logging.googleapis.com/sourceLocation": {
        "function": "abc.def.ghi.MyClass.recordSendError"
    },
    "logging.googleapis.com/insertId": "1261298",
    "_exception": {
        "class": "org.apache.kafka.common.errors.TimeoutException",
        "message": "problem specifics",
        "stackTrace": "MyException: problem specifics.\nMore details ..."
    },
    "_thread": "mythread-1",
    "_logger": "abc.def.ghi.MyClass"
}
jmini commented 1 year ago

There are two pull requests open for this:

Alternatively this project can be considered: https://github.com/benkard/quarkus-googlecloud-jsonlogging