As a start, you can get the last query that was run using $this->db->last_query()
So we could get the query as a string with the following snippet:
// strip out line returns, new lines and tabs
$query = str_replace( array("\r", "\n", "\t"), '', trim($this->db->last_query()) );
Once you have a string, we can log to the error log:
error_log( "Last database query: " . $query );
Note: Depending on your application logic and traffic, this could add tons of extra bloat to the error log over time, so I would recommend this is only used as a temporary troubleshooting tool.
Hope that helps.