logread: move output connection setup code out of main loop