Use logger instead of stdout and stderr

Implements suggestion from #409