log.JsonFormatter
A formatter class that outputs logs in JSON format.
Usage
log.JsonFormatter()Methods
| Name | Description |
|---|---|
| __init__() | Initialize the formatter. |
| format() | Format the specified record as a JSON string with non-serializable types |
__init__()
Initialize the formatter.
Usage
__init__(include_traceback=True, *args, **kwargs)
format()
Format the specified record as a JSON string with non-serializable types
Usage
format(record)converted using repr.
This will format the log record as JSON with the following values (in order): - timestamp: The ISO 8601-formatted timestamp of the log message. - service: The name of the service where the log was generated. - instance: The instance ID of the service where the log was generated. - level: The log’s severity. - name: The name of the logger. - correlation_id: The correlation ID, if set, from the current context. - message: The message that was logged, formatted with any arguments. - details: Any additional values included at time of logging. - exception: If an exception was logged, the exception info.