Improve logging output and show lost connection in log.