How to get last insert ID of drupal_write_record I need to get the last inserted id in drupal 7. I am using 

drupal_write_record('user_log', $log)


How we can get the last_instered_id?
Assuming your {user_log} table has a PRIMARY KEY with it, or something else serial, then it should be set in in the array you passed to it.  In your case, it would be something like

$last_log_id = $log['log_id'];