Store log into database