Thnx again Robert, for anyone else with a similar requirement I ended up with....

except Exception as e: import sys; from uio import StringIO s=StringIO(); sys.print_exception(e, s) s=s.getvalue(); s=s.split('\n') line=s[1].split(','); line=line[1]; error=s[2]; err=error+line; print(err) with open ('error.log', 'a') as f: f.write(err)