Possible change for #1288

@danfruehauf  a possible change to avoid huge logs associated with #1288

Only log exception details (including stack trace) if logging is set to 'debug'. This way most of the time there won't be big logs with stack traces, but we can turn them on if the cause of the problem is not obvious from the URL alone.