diff --git a/tests/pktact.py b/tests/pktact.py
index fd1b014..ef7505e 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -35,8 +35,6 @@
 #@var port_map Local copy of the configuration map from OF port
 # numbers to OS interfaces
 pa_port_map = None
-#@var pa_logger Local logger object
-pa_logger = None
 #@var pa_config Local copy of global configuration data
 pa_config = None
 
@@ -100,11 +98,8 @@
     basic.test_set_init(config)
 
     global pa_port_map
-    global pa_logger
     global pa_config
 
-    pa_logger = logging.getLogger("pkt_act")
-    pa_logger.info("Initializing test set")
     pa_port_map = config["port_map"]
     pa_config = config
 
@@ -137,12 +132,12 @@
         act = action.action_output()
 
         for idx in range(len(of_ports)):
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
             ingress_port = of_ports[idx]
             egress_port = of_ports[(idx + 1) % len(of_ports)]
-            pa_logger.info("Ingress " + str(ingress_port) + 
+            logging.info("Ingress " + str(ingress_port) + 
                              " to egress " + str(egress_port))
 
             match.in_port = ingress_port
@@ -154,12 +149,12 @@
             act.port = egress_port
             self.assertTrue(request.actions.add(act), "Could not add action")
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + 
+            logging.info("Sending packet to dp port " + 
                            str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
 
@@ -172,7 +167,7 @@
             (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
                                                                 exp_pkt=exp_pkt_arg)
             self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-            pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " + 
+            logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " + 
                          str(rcv_port))
             self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
             self.assertEqual(str(pkt), str(rcv_pkt),
@@ -206,7 +201,7 @@
                         "Could not generate flow match from pkt")
         act = action.action_output()
 
-        rv = delete_all_flows(self.controller, pa_logger)
+        rv = delete_all_flows(self.controller)
         self.assertEqual(rv, 0, "Failed to delete all flows")
 
         ingress_port = of_ports[0]
@@ -220,12 +215,12 @@
         act.max_len = 65535
         self.assertTrue(request.actions.add(act), "Could not add action")
 
-        pa_logger.info("Inserting flow")
+        logging.info("Inserting flow")
         rv = self.controller.message_send(request)
         self.assertTrue(rv != -1, "Error installing flow mod")
         self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-        pa_logger.info("Sending packet to dp port " +
+        logging.info("Sending packet to dp port " +
                         str(ingress_port))
         self.dataplane.send(ingress_port, str(pkt))
 
@@ -234,8 +229,8 @@
         self.assertTrue(response is not None,
                         'Packet in message not received by controller')
         if not dataplane.match_exp_pkt(pkt, response.data):
-            pa_logger.debug("Sent %s" % format_packet(pkt))
-            pa_logger.debug("Resp %s" % format_packet(response.data))
+            logging.debug("Sent %s" % format_packet(pkt))
+            logging.debug("Resp %s" % format_packet(response.data))
             self.assertTrue(False,
                             'Response packet does not match send packet' +
                              ' for controller port')
@@ -291,12 +286,12 @@
             egress_port = of_ports[(idx + 1) % len(of_ports)]
 
             for egress_queue_id in self.portQueuesGet(queue_stats, egress_port):
-                pa_logger.info("Ingress " + str(ingress_port)
+                logging.info("Ingress " + str(ingress_port)
                                + " to egress " + str(egress_port)
                                + " queue " + str(egress_queue_id)
                                )
 
-                rv = delete_all_flows(self.controller, pa_logger)
+                rv = delete_all_flows(self.controller)
                 self.assertEqual(rv, 0, "Failed to delete all flows")
 
                 match.in_port = ingress_port
@@ -309,7 +304,7 @@
                 act.queue_id = egress_queue_id
                 self.assertTrue(request.actions.add(act), "Could not add action")
 
-                pa_logger.info("Inserting flow")
+                logging.info("Inserting flow")
                 rv = self.controller.message_send(request)
                 self.assertTrue(rv != -1, "Error installing flow mod")
                 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -322,7 +317,7 @@
                 (qs_before, p) = self.controller.transact(request)
                 self.assertNotEqual(qs_before, None, "Queue stats request failed")
 
-                pa_logger.info("Sending packet to dp port " + 
+                logging.info("Sending packet to dp port " + 
                                str(ingress_port))
                 self.dataplane.send(ingress_port, str(pkt))
                 
@@ -335,7 +330,7 @@
                     (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
                                                                         exp_pkt=exp_pkt_arg)
                     self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-                    pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " + 
+                    logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " + 
                                     str(rcv_port))
                     self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
                     self.assertEqual(str(pkt), str(rcv_pkt),
@@ -414,17 +409,17 @@
             ingress_port = of_ports[idx]
             egress_port = ofp.OFPP_CONTROLLER
 
-            pa_logger.info("Ingress port " + str(ingress_port)
+            logging.info("Ingress port " + str(ingress_port)
                            + ", controller port queues " 
                            + str(self.portQueuesGet(queue_stats, egress_port)))
 
             for egress_queue_id in self.portQueuesGet(queue_stats, egress_port):
-                pa_logger.info("Ingress " + str(ingress_port)
+                logging.info("Ingress " + str(ingress_port)
                                + " to egress " + str(egress_port)
                                + " queue " + str(egress_queue_id)
                                )
 
-                rv = delete_all_flows(self.controller, pa_logger)
+                rv = delete_all_flows(self.controller)
                 self.assertEqual(rv, 0, "Failed to delete all flows")
 
                 match.in_port = ingress_port
@@ -437,7 +432,7 @@
                 act.queue_id = egress_queue_id
                 self.assertTrue(request.actions.add(act), "Could not add action")
 
-                pa_logger.info("Inserting flow")
+                logging.info("Inserting flow")
                 rv = self.controller.message_send(request)
                 self.assertTrue(rv != -1, "Error installing flow mod")
                 self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
@@ -450,7 +445,7 @@
                 (qs_before, p) = self.controller.transact(request)
                 self.assertNotEqual(qs_before, None, "Queue stats request failed")
 
-                pa_logger.info("Sending packet to dp port " + 
+                logging.info("Sending packet to dp port " + 
                                str(ingress_port))
                 self.dataplane.send(ingress_port, str(pkt))
                 
@@ -472,8 +467,8 @@
                 self.assertTrue(response is not None, 
                                'Packet in message not received by controller')
                 if not dataplane.match_exp_pkt(pkt, response.data):
-                    basic_logger.debug("Sent %s" % format_packet(pkt))
-                    basic_logger.debug("Resp %s" % format_packet(response.data))
+                    logging.debug("Sent %s" % format_packet(pkt))
+                    logging.debug("Resp %s" % format_packet(response.data))
                     self.assertTrue(False,
                                     'Response packet does not match send packet' +
                                     ' for controller port')
@@ -537,13 +532,13 @@
         act = action.action_output()
 
         for idx in range(len(of_ports)):
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
             ingress_port = of_ports[idx]
             egress_port1 = of_ports[(idx + 1) % len(of_ports)]
             egress_port2 = of_ports[(idx + 2) % len(of_ports)]
-            pa_logger.info("Ingress " + str(ingress_port) + 
+            logging.info("Ingress " + str(ingress_port) + 
                            " to egress " + str(egress_port1) + " and " +
                            str(egress_port2))
 
@@ -556,21 +551,21 @@
             self.assertTrue(request.actions.add(act), "Could not add action1")
             act.port = egress_port2
             self.assertTrue(request.actions.add(act), "Could not add action2")
-            # pa_logger.info(request.show())
+            # logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + 
+            logging.info("Sending packet to dp port " + 
                            str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
             yes_ports = set([egress_port1, egress_port2])
             no_ports = set(of_ports).difference(yes_ports)
 
             receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports,
-                              self, pa_logger, pa_config)
+                              self, pa_config)
 
 class DirectMCNonIngress(basic.SimpleDataPlane):
     """
@@ -597,10 +592,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + 
+            logging.info("Ingress " + str(ingress_port) + 
                            " all non-ingress ports")
             match.in_port = ingress_port
 
@@ -613,18 +608,18 @@
                 act.port = egress_port
                 self.assertTrue(request.actions.add(act), 
                                 "Could not add output to " + str(egress_port))
-            pa_logger.debug(request.show())
+            logging.debug(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
             yes_ports = set(of_ports).difference([ingress_port])
             receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
-                              self, pa_logger, pa_config)
+                              self, pa_config)
 
 
 class DirectMC(basic.SimpleDataPlane):
@@ -652,10 +647,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+            logging.info("Ingress " + str(ingress_port) + " to all ports")
             match.in_port = ingress_port
 
             request = message.flow_mod()
@@ -668,17 +663,16 @@
                     act.port = egress_port
                 self.assertTrue(request.actions.add(act), 
                                 "Could not add output to " + str(egress_port))
-            # pa_logger.info(request.show())
+            # logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
-            receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
-                              pa_logger, pa_config)
+            receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
 
 class Flood(basic.SimpleDataPlane):
     """
@@ -703,10 +697,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+            logging.info("Ingress " + str(ingress_port) + " to all ports")
             match.in_port = ingress_port
 
             request = message.flow_mod()
@@ -715,18 +709,18 @@
             act.port = ofp.OFPP_FLOOD
             self.assertTrue(request.actions.add(act), 
                             "Could not add flood port action")
-            pa_logger.info(request.show())
+            logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
             yes_ports = set(of_ports).difference([ingress_port])
             receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
-                              self, pa_logger, pa_config)
+                              self, pa_config)
 
 class FloodPlusIngress(basic.SimpleDataPlane):
     """
@@ -752,10 +746,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+            logging.info("Ingress " + str(ingress_port) + " to all ports")
             match.in_port = ingress_port
 
             request = message.flow_mod()
@@ -767,17 +761,16 @@
             act.port = ofp.OFPP_IN_PORT
             self.assertTrue(request.actions.add(act), 
                             "Could not add ingress port for output")
-            pa_logger.info(request.show())
+            logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
-            receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
-                              pa_logger, pa_config)
+            receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
 
 class All(basic.SimpleDataPlane):
     """
@@ -802,10 +795,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+            logging.info("Ingress " + str(ingress_port) + " to all ports")
             match.in_port = ingress_port
 
             request = message.flow_mod()
@@ -814,18 +807,18 @@
             act.port = ofp.OFPP_ALL
             self.assertTrue(request.actions.add(act), 
                             "Could not add ALL port action")
-            pa_logger.info(request.show())
+            logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
             yes_ports = set(of_ports).difference([ingress_port])
             receive_pkt_check(self.dataplane, pkt, yes_ports, [ingress_port],
-                              self, pa_logger, pa_config)
+                              self, pa_config)
 
 class AllPlusIngress(basic.SimpleDataPlane):
     """
@@ -851,10 +844,10 @@
         act = action.action_output()
 
         for ingress_port in of_ports:
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
-            pa_logger.info("Ingress " + str(ingress_port) + " to all ports")
+            logging.info("Ingress " + str(ingress_port) + " to all ports")
             match.in_port = ingress_port
 
             request = message.flow_mod()
@@ -866,17 +859,16 @@
             act.port = ofp.OFPP_IN_PORT
             self.assertTrue(request.actions.add(act), 
                             "Could not add ingress port for output")
-            pa_logger.info(request.show())
+            logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
-            receive_pkt_check(self.dataplane, pkt, of_ports, [], self,
-                              pa_logger, pa_config)
+            receive_pkt_check(self.dataplane, pkt, of_ports, [], self, pa_config)
             
 class FloodMinusPort(basic.SimpleDataPlane):
     """
@@ -903,15 +895,14 @@
         act = action.action_output()
 
         for idx in range(len(of_ports)):
-            rv = delete_all_flows(self.controller, pa_logger)
+            rv = delete_all_flows(self.controller)
             self.assertEqual(rv, 0, "Failed to delete all flows")
 
             ingress_port = of_ports[idx]
             no_flood_idx = (idx + 1) % len(of_ports)
             no_flood_port = of_ports[no_flood_idx]
             rv = port_config_set(self.controller, no_flood_port,
-                                 ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD,
-                                 pa_logger)
+                                 ofp.OFPPC_NO_FLOOD, ofp.OFPPC_NO_FLOOD)
             self.assertEqual(rv, 0, "Failed to set port config")
 
             match.in_port = ingress_port
@@ -922,24 +913,23 @@
             act.port = ofp.OFPP_FLOOD
             self.assertTrue(request.actions.add(act), 
                             "Could not add flood port action")
-            pa_logger.info(request.show())
+            logging.info(request.show())
 
-            pa_logger.info("Inserting flow")
+            logging.info("Inserting flow")
             rv = self.controller.message_send(request)
             self.assertTrue(rv != -1, "Error installing flow mod")
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
-            pa_logger.info("No flood port is " + str(no_flood_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("No flood port is " + str(no_flood_port))
             self.dataplane.send(ingress_port, str(pkt))
             no_ports = set([ingress_port, no_flood_port])
             yes_ports = set(of_ports).difference(no_ports)
-            receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports, self,
-                              pa_logger, pa_config)
+            receive_pkt_check(self.dataplane, pkt, yes_ports, no_ports, self, pa_config)
 
             # Turn no flood off again
             rv = port_config_set(self.controller, no_flood_port,
-                                 0, ofp.OFPPC_NO_FLOOD, pa_logger)
+                                 0, ofp.OFPPC_NO_FLOOD)
             self.assertEqual(rv, 0, "Failed to reset port config")
 
             #@todo Should check no other packets received
@@ -951,9 +941,8 @@
 class BaseMatchCase(basic.SimpleDataPlane):
     def setUp(self):
         basic.SimpleDataPlane.setUp(self)
-        self.logger = pa_logger
     def runTest(self):
-        self.logger.info("BaseMatchCase")
+        logging.info("BaseMatchCase")
 
 class ExactMatch(BaseMatchCase):
     """
@@ -1004,7 +993,7 @@
         self.flowMsgs = {}
 
     def _ClearTable(self):
-        rc = delete_all_flows(self.controller, self.logger)
+        rc = delete_all_flows(self.controller)
         self.assertEqual(rc, 0, "Failed to delete all flows")
         self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
@@ -1039,7 +1028,7 @@
             self._ClearTable()
 
         # Sanity check flow at lower priority from pA to pB
-        self.logger.info("runPrioFlows(pA=%d,pB=%d,pC=%d,ph=%d,pl=%d"
+        logging.info("runPrioFlows(pA=%d,pB=%d,pC=%d,ph=%d,pl=%d"
                          % (portA, portB, portC, prioHigher, prioLower))
 
         # Sanity check flow at lower priority from pA to pC
@@ -1072,7 +1061,7 @@
                                   wildcards=wildcards,
                                   egr_ports=egp)
         request.priority = prio
-        self.logger.debug("Install flow with priority " + str(prio))
+        logging.debug("Install flow with priority " + str(prio))
         flow_msg_install(self, request, clear_table_override=False)
         self.flowMsgs[prio] = request
         
@@ -1082,7 +1071,7 @@
             msg.command = ofp.OFPFC_DELETE_STRICT
             # This *must* be set for DELETE
             msg.out_port = ofp.OFPP_NONE
-            self.logger.debug("Remove flow with priority " + str(prio))
+            logging.debug("Remove flow with priority " + str(prio))
             self.controller.message_send(msg)
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
         else:
@@ -1093,10 +1082,8 @@
         if pkt == None:
             pkt = self.pkt
 
-        self.logger.info("Pkt match test: " + str(inp) + 
-                         " to " + str(egp))
-        self.logger.debug("Send packet: " + str(inp) + " to " 
-                            + str(egp))
+        logging.info("Pkt match test: " + str(inp) + " to " + str(egp))
+        logging.debug("Send packet: " + str(inp) + " to " + str(egp))
         self.dataplane.send(inp, str(pkt))
         receive_pkt_verify(self, egp, pkt, inp)
 
@@ -1321,8 +1308,8 @@
         of_ports = pa_port_map.keys()
         of_ports.sort()
         ing_port = of_ports[0]
-        pa_logger.info("Sending packet to " + str(ing_port))
-        pa_logger.debug("Data: " + str(pkt).encode('hex'))
+        logging.info("Sending packet to " + str(ing_port))
+        logging.debug("Data: " + str(pkt).encode('hex'))
         self.dataplane.send(ing_port, str(pkt))
 
 class PacketOnlyTagged(basic.DataPlaneOnly):
@@ -1335,8 +1322,8 @@
         of_ports = pa_port_map.keys()
         of_ports.sort()
         ing_port = of_ports[0]
-        pa_logger.info("Sending packet to " + str(ing_port))
-        pa_logger.debug("Data: " + str(pkt).encode('hex'))
+        logging.info("Sending packet to " + str(ing_port))
+        logging.debug("Data: " + str(pkt).encode('hex'))
         self.dataplane.send(ing_port, str(pkt))
 
 test_prio["PacketOnly"] = -1
@@ -1393,7 +1380,7 @@
         ing_port = of_ports[0]
         egr_ports = of_ports[1]
         
-        rv = delete_all_flows(self.controller, pa_logger)
+        rv = delete_all_flows(self.controller)
         self.assertEqual(rv, 0, "Failed to delete all flows")
 
         len_untagged = 100
@@ -1412,12 +1399,12 @@
                                   action_list=[vid_act])
         flow_msg_install(self, request)
 
-        pa_logger.debug("Send untagged packet: " + str(ing_port) + " to " + 
+        logging.debug("Send untagged packet: " + str(ing_port) + " to " + 
                         str(egr_ports))
         self.dataplane.send(ing_port, str(untagged_pkt))
         receive_pkt_verify(self, egr_ports, exp_pkt, ing_port)
 
-        pa_logger.debug("Send tagged packet: " + str(ing_port) + " to " + 
+        logging.debug("Send tagged packet: " + str(ing_port) + " to " + 
                         str(egr_ports))
         self.dataplane.send(ing_port, str(tagged_pkt))
         receive_pkt_verify(self, egr_ports, exp_pkt, ing_port)
@@ -1724,7 +1711,7 @@
         flow_count = test_param_get(self.config, 'ft_flow_count', default=20)
         iter_count = test_param_get(self.config, 'ft_iter_count', default=10)
 
-        pa_logger.info("Running flow toggle with %d flows, %d iterations" %
+        logging.info("Running flow toggle with %d flows, %d iterations" %
                        (flow_count, iter_count))
         acts = []
         acts.append(action.action_output())
@@ -1758,8 +1745,8 @@
                 flows[toggle].append(msg)
 
         # Show two sample flows
-        pa_logger.debug(flows[0][0].show())
-        pa_logger.debug(flows[1][0].show())
+        logging.debug(flows[0][0].show())
+        logging.debug(flows[1][0].show())
 
         # Install the first set of flows
         for f_idx in range(flow_count):
@@ -1767,7 +1754,7 @@
             self.assertTrue(rv != -1, "Error installing flow %d" % f_idx)
         self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
     
-        pa_logger.info("Installed %d flows" % flow_count)
+        logging.info("Installed %d flows" % flow_count)
     
         # Repeatedly modify all the flows back and forth
         updates = 0
@@ -1776,7 +1763,7 @@
         start = time.time()
         for iter_idx in range(iter_count):
             if not iter_idx % mod_val:
-                pa_logger.info("Flow Toggle: iter %d of %d. " %
+                logging.info("Flow Toggle: iter %d of %d. " %
                                (iter_idx, iter_count) + 
                                "%d updates in %d secs" %
                                (updates, time.time() - start))
@@ -1792,8 +1779,8 @@
 
         end = time.time()
         divisor = end - start or (end - start + 1)
-        pa_logger.info("Flow toggle: %d iterations" % iter_count)
-        pa_logger.info("   %d flow mods in %d secs, %d mods/sec" %
+        logging.info("Flow toggle: %d iterations" % iter_count)
+        logging.info("   %d flow mods in %d secs, %d mods/sec" %
                        (updates, end - start, updates/divisor))
             
 
@@ -1829,11 +1816,11 @@
     def runTest(self):
         count = test_param_get(self.config, 'iter_count', default=10)
         tests_done = 0
-        pa_logger.info("Running iteration test " + str(count) + " times")
+        logging.info("Running iteration test " + str(count) + " times")
         start = time.time()
         last = start
         for idx in range(count):
-            pa_logger.info("Iteration " + str(idx + 1))
+            logging.info("Iteration " + str(idx + 1))
             for cls in iter_classes:
                 test = cls()
                 test.inheritSetup(self)
@@ -1842,17 +1829,17 @@
                 # Report update about every minute, between tests
                 if time.time() - last > 60:
                     last = time.time()
-                    pa_logger.info(
+                    logging.info(
                         "IterCases: Iter %d of %d; Ran %d tests in %d " %
                         (idx, count, tests_done, last - start) + 
                         "seconds so far")
         stats = all_stats_get(self)
         last = time.time()
-        pa_logger.info("\nIterCases ran %d tests in %d seconds." %
+        logging.info("\nIterCases ran %d tests in %d seconds." %
                        (tests_done, last - start))
-        pa_logger.info("    flows: %d. packets: %d. bytes: %d" %
+        logging.info("    flows: %d. packets: %d. bytes: %d" %
                        (stats["flows"], stats["packets"], stats["bytes"]))
-        pa_logger.info("    active: %d. lookups: %d. matched %d." %
+        logging.info("    active: %d. lookups: %d. matched %d." %
                        (stats["active"], stats["lookups"], stats["matched"]))
 
 # Don't run by default
@@ -1903,14 +1890,14 @@
         of_ports.sort()
         self.assertTrue(len(of_ports) > 1, "Not enough ports for test")
 
-        delete_all_flows(self.controller, pa_logger)
+        delete_all_flows(self.controller)
 
         pkt = simple_tcp_packet()
         ingress_port = of_ports[0]
         egress_port = of_ports[1]
 
         def testField(field, mask):
-            pa_logger.info("Testing field %s" % field)
+            logging.info("Testing field %s" % field)
 
             def addFlow(matching, priority, output_port):
                 match = packet_to_flow_match(self, pkt)
@@ -1932,7 +1919,7 @@
                 act = action.action_output()
                 act.port = output_port
                 self.assertTrue(request.actions.add(act), "Could not add action")
-                pa_logger.info("Inserting flow")
+                logging.info("Inserting flow")
                 self.controller.message_send(request)
 
             # This flow should match.
@@ -1942,7 +1929,7 @@
 
             self.assertEqual(do_barrier(self.controller), 0, "Barrier failed")
 
-            pa_logger.info("Sending packet to dp port " + str(ingress_port))
+            logging.info("Sending packet to dp port " + str(ingress_port))
             self.dataplane.send(ingress_port, str(pkt))
 
             exp_pkt_arg = None
@@ -1954,7 +1941,7 @@
             (rcv_port, rcv_pkt, pkt_time) = self.dataplane.poll(port_number=exp_port,
                                                                 exp_pkt=exp_pkt_arg)
             self.assertTrue(rcv_pkt is not None, "Did not receive packet")
-            pa_logger.debug("Packet len " + str(len(rcv_pkt)) + " in on " + str(rcv_port))
+            logging.debug("Packet len " + str(len(rcv_pkt)) + " in on " + str(rcv_port))
             self.assertEqual(rcv_port, egress_port, "Unexpected receive port")
             self.assertEqual(str(pkt), str(rcv_pkt), 'Response packet does not match send packet')
 
