Changing stacktrace printing to logging