Logging failed statement

Write to log content of sql statement which failed.