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

Allow simultaneously enabling structured logging and "standard" logging #8588

Closed
clokep opened this issue Oct 19, 2020 · 2 comments · Fixed by #8607
Closed

Allow simultaneously enabling structured logging and "standard" logging #8588

clokep opened this issue Oct 19, 2020 · 2 comments · Fixed by #8607
Assignees

Comments

@clokep
Copy link
Member

clokep commented Oct 19, 2020

Currently the structured logging code in Synapse cannot be run at the same time as the "standard" logging code. This is undesirable for a couple of reasons:

  • You cannot run it at the same time. 😄
  • It can make it hard to transition from standard logging to structured logging since you cannot run both and verify the results before disabling standard logging.
@clokep
Copy link
Member Author

clokep commented Oct 19, 2020

One of the reasons that these are incompatible is that by default the standard logging module is used and the Twisted logger is redirected to it. The Twisted logger captures log messages, but passes them to the Python logger to output.

If structured logging is enabled (by setting structured: true), then the opposite happens and the standard logging module is redirected to the Twisted logger and output is pushed out via the Twisted logger system.

I think that we'll want to standardize Synapse to use one or the other of these systems. We cannot just switch to the Python logging system though, as the STDLibLogObserver notes:

Warning: specific logging configurations (example: network) can lead to this observer blocking. Nothing is done here to prevent that, so be sure to not to configure the standard library logging module to block when used in conjunction with this module: code within Twisted, such as twisted.web, assumes that logging does not block.

@clokep
Copy link
Member Author

clokep commented Oct 20, 2020

After some conversation the plan here is to try to consolidate the two logging methods via the standard library logging module.

This would mean that when using structured logging to a remote server, any messages sent via Twisted loggers would end up going from (Twisted logger) -> (stdlib logger) -> (Twisted protocol), while things logged via the standard library loggers would simply go (stdlib logger) -> (Twisted protocol).

I think much of the code to negotiate the connections and buffer data can be re-used, but the configuration code will be simplified to use the standard dictConfig by exposing a handler/formatter publicly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant