Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Improve structured logging #8683

Open
Open
@clokep

Description

@clokep

Building on #8588 there's a desire to improve the output of Synapse structured logging.

Currently a "standard" log line would be turned into JSON (this was a curl to /_matrix/client/r0/login to get the login flows, but other logs look similar):

2020-10-29 07:36:00,762 - synapse.access.http.8080 - 315 - INFO - GET-0 - - - 8080 - {None} Processed request: 0.000sec/-0.000sec (0.000sec, 0.000sec) (0.000sec/0.000sec/0) 285B 200 "GET /_matrix/client/r0/login HTTP/1.1" "curl/7.64.1" [0 dbevts]

This would transform to (note that whitespace was added for visibility, normally this would be a single line with no whitespaec between JSON separators):

{
    "log": "- - 8080 - {None} Processed request: 0.000sec/-0.000sec (0.000sec, 0.000sec) (0.000sec/0.000sec/0) 285B 200 \"GET /_matrix/client/r0/login HTTP/1.1\" \"curl/7.64.1\" [0 dbevts]",
    "namespace": "synapse.access.http.8080",
    "level": "INFO",
    "time": 1603971360.76,
    "request": "GET-0",
    "scope": null,
    "server_name": "localhost:8480"
}

A few improvements we'll want to make:

  • The log line includes a formatted message, which makes it difficult to search in a structured way.
  • Currently logging a message with additional fields requires including the fields twice (using the standard logging flow and the extra keyword to the logger).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LoggingSynapse's logs (structured or otherwise). Not metrics.T-EnhancementNew features, changes in functionality, improvements in performance, or user-facing enhancements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions