Write exception to log