Allow duplicate logger closes

[#56061680]
Improved logger handling in tests

Ensure that each test which modifies a logger sets up the logger
correct afterwards so remaining tests continue to work.

This is work in progress as it depends on test writers copying the
relevant before and after logic into their tests. We need to
investigate building this into the test infrastructure in some way
so that all tests can get the necessary function in a maintainable
way.

[#56061680]