Print stack trace to error log file for debugging, thanks to Pavel Pimenov and Timo Bingmann