Attempt at better error logging, including during startup/shutdown.