Added logging and logging option to database operations.