Improved logging robustness and handling in tests

Make the logging code more robust and add diagnostics.

Use before(:all) in spec_helper.rb to ensure a normal logger is
present. This avoids example groups having to restore a normal logger
if they have created a special logger.

[#56061680]

Suppress output from download_cache_spec.rb

Create logger based on StringIO $stderr to avoid logs appearing on
STDERR. Set $stdout to a StringIO to avoid download failures appearing
on STDOUT.

[#56330430]
Merge 56061680-logger-robustness-improvements to master

[Completes #56061680]