I’ve published CaptureLogger 1.0, a very light modification to ExUnit.CaptureLogger (mostly to ExUnit.CaptureServer) that supports passing a formatter to be used instead of Logger.default_formatter/0. This allows testing log captures with LoggerJSON, for example, which matters particularly for testing LoggerJSON.Redactor implementations or for metadata that is more complex than the default Logger formatter permits.
This is something that could easily be added to ExUnit if the core team is interested (I’m happy to submit a PR) but this library will be useful for older version of Elixir that don’t include such a change.
The excellent news is that this will be native in a future version of Elixir.
CaptureLogger probably won’t be updated to match the more limited configuration option that is in ExUnit.CaptureLog with this, but a future version might start warning about this when the next version of Elixir is closer to release, so that it will be simpler to convert when upgrading (CaptureLogger will still be useful for all versions before the version of Elixir that contains this).