diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
index 087a5c9..9a8b3e0 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
@@ -276,7 +276,7 @@
 
         if (!configured()) {
             log.warn("Missing DHCP6 relay server config. Abort packet processing");
-            log.warn("dhcp6 payload {}", dhcp6Payload);
+            log.trace("dhcp6 payload {}", dhcp6Payload);
 
             return;
         }
@@ -294,7 +294,6 @@
 
 
         if (MSG_TYPE_FROM_CLIENT.contains(msgType)) {
-
             InternalPacket ethernetClientPacket =
                     processDhcp6PacketFromClient(context, receivedPacket, receivingInterfaces);
             if (ethernetClientPacket != null) {
@@ -302,14 +301,14 @@
             }
 
         } else if (MSG_TYPE_FROM_SERVER.contains(msgType)) {
-            log.warn("calling processDhcp6PacketFromServer with RELAY_REPL", msgType);
+            log.debug("calling processDhcp6PacketFromServer with RELAY_REPL", msgType);
             InternalPacket ethernetPacketReply =
                     processDhcp6PacketFromServer(context, receivedPacket, receivingInterfaces);
             if (ethernetPacketReply != null) {
                 forwardPacket(ethernetPacketReply);
             }
         } else {
-            log.warn("Not so fast, packet type {} not supported yet", msgType);
+            log.warn("DHCP type {} not supported yet", msgType);
         }
     }
 
@@ -396,7 +395,7 @@
                 }
             }
         } else {
-            log.warn("directlyConnected  true.");
+            log.debug("directlyConnected  true.");
             return true;
         }
     }
@@ -454,7 +453,7 @@
                     dhcp6Parent = dhcp6Child;
                 }
             } else {
-                log.warn("malformed pkt! Expected dhcp6 within relay pkt, but no dhcp6 leaf found.");
+                log.warn("Expected dhcp6 within relay pkt, but no dhcp6 leaf found.");
                 break;
             }
         }
@@ -573,7 +572,7 @@
      * @return IpPrefix Prefix Delegation prefix, or null if not exists.
      */
     private IpPrefix extractPrefix(DHCP6 dhcp6) {
-        log.warn("extractPrefix  enters {}", dhcp6);
+        log.trace("extractPrefix  enters {}", dhcp6);
 
         // extract prefix
         IpPrefix  prefixPrefix = null;
@@ -589,27 +588,26 @@
 
         Optional<Dhcp6IaPrefixOption> iaPrefixOption;
         if (iaPdOption.isPresent()) {
-            log.warn("IA_PD option found {}", iaPdOption);
+            log.trace("IA_PD option found {}", iaPdOption);
 
             iaPrefixOption = iaPdOption.get().getOptions().stream()
                     .filter(opt -> opt instanceof Dhcp6IaPrefixOption)
                     .map(opt -> (Dhcp6IaPrefixOption) opt)
                     .findFirst();
         } else {
-            log.warn("IA_PD option NOT found");
+            log.trace("IA_PD option NOT found");
 
             iaPrefixOption = Optional.empty();
         }
         if (iaPrefixOption.isPresent()) {
-            log.warn("IAPrefix Option within IA_PD option found {}", iaPrefixOption);
+            log.trace("IAPrefix Option within IA_PD option found {}", iaPrefixOption);
 
             prefixAddress = iaPrefixOption.get().getIp6Prefix();
             int prefixLen = (int) iaPrefixOption.get().getPrefixLength();
-            log.warn("Prefix length is  {} bits", prefixLen);
+            log.trace("Prefix length is  {} bits", prefixLen);
             prefixPrefix = IpPrefix.valueOf(prefixAddress, prefixLen);
-
         } else {
-            log.warn("Can't find IPv6 prefix from DHCPv6 {}", dhcp6);
+            log.trace("Can't find IPv6 prefix from DHCPv6 {}", dhcp6);
         }
 
         return prefixPrefix;
@@ -734,7 +732,7 @@
                     // Replace the ip when dhcp server give the host new ip address
                     providerService.hostDetected(hostId, desc, false);
                 } else {
-                    log.warn("ipAddress not found. Do not add Host for directly connected.");
+                    log.debug("ipAddress not found. Do not add Host for directly connected.");
                 }
             } else {
                 // Add to route store if it does not connect to network directly
@@ -749,19 +747,19 @@
                 DHCP6 leafDhcp = getDhcp6Leaf(embeddedDhcp6);
                 ip = extractIpAddress(leafDhcp);
                 if (ip == null) {
-                    log.warn("ip is null");
+                    log.debug("ip is null");
                 } else {
                     Route routeForIP = new Route(Route.Source.STATIC, ip.toIpPrefix(), nextHopIp);
-                    log.warn("adding Route of 128 address for indirectly connected.");
+                    log.debug("adding Route of 128 address for indirectly connected.");
                     routeStore.updateRoute(routeForIP);
                 }
 
                 IpPrefix ipPrefix = extractPrefix(leafDhcp);
                 if (ipPrefix == null) {
-                    log.warn("ipPrefix is null ");
+                    log.debug("ipPrefix is null ");
                 } else {
                     Route routeForPrefix = new Route(Route.Source.STATIC, ipPrefix, nextHopIp);
-                    log.warn("adding Route of PD for indirectly connected.");
+                    log.debug("adding Route of PD for indirectly connected.");
                     routeStore.updateRoute(routeForPrefix);
                     if (this.dhcpFpmEnabled) {
                         FpmRecord record = new FpmRecord(ipPrefix, nextHopIp, FpmRecord.Type.DHCP_RELAY);
@@ -846,12 +844,12 @@
             log.warn("No IP v6 address for server Interface {}", serverInterface);
             return null;
         }
-        Ethernet etherReply = (Ethernet) clientPacket.duplicate();
+        Ethernet etherReply = clientPacket.duplicate();
         etherReply.setSourceMACAddress(macFacingServer);
         if ((directConnFlag && dhcpConnectMac == null)  ||
                 !directConnFlag && indirectDhcpConnectMac == null && dhcpConnectMac == null)   {
-            log.warn("Packet received from {} connected client.", directConnFlag ? "directly" : "indirectly");
-            log.warn("DHCP6 {} not yet resolved .. Aborting DHCP packet processing from client on port: {}",
+            log.trace("Packet received from {} connected client.", directConnFlag ? "directly" : "indirectly");
+            log.debug("DHCP6 {} not yet resolved .. Aborting DHCP packet processing from client on port: {}",
                      (dhcpGatewayIp == null) ? "server IP " + dhcpServerIp
                              : "gateway IP " + dhcpGatewayIp,
                      clientInterfaces.iterator().next().connectPoint());
@@ -891,7 +889,7 @@
 
         } else {
             if (indirectDhcpServerIp == null) {
-                log.warn("indirect DhcpServerIp not available, use default DhcpServerIp {}",
+                log.debug("indirect DhcpServerIp not available, use default DhcpServerIp {}",
                          HexString.toHexString(dhcpServerIp.toOctets()));
              } else {
                  // Indirect case, replace destination to indirect dhcp server if exist
@@ -910,11 +908,11 @@
              }
              if (indirectRelayAgentIpFromCfg == null) {
                  dhcp6Relay.setLinkAddress(relayAgentIp.toOctets());
-                 log.warn("indirect connection: relayAgentIp NOT availale from config file! Use dynamic. {}",
+                 log.trace("indirect connection: relayAgentIp NOT availale from config file! Use dynamic. {}",
                           HexString.toHexString(relayAgentIp.toOctets(), ":"));
              } else {
                  dhcp6Relay.setLinkAddress(indirectRelayAgentIpFromCfg.toOctets());
-                 log.debug("indirect connection: relayAgentIp from config file is available! {}",
+                 log.trace("indirect connection: relayAgentIp from config file is available! {}",
                            HexString.toHexString(indirectRelayAgentIpFromCfg.toOctets(), ":"));
              }
          }
@@ -945,7 +943,7 @@
          vlanIdBytes[1] = (byte) ((clientPacket.getVlanID() >> 8) & 0xff);
          byte[] interfaceIdBytes = new byte[clientSoureMacBytes.length +
                  inPortStringBytes.length + vlanIdBytes.length];
-         log.debug("Length: interfaceIdBytes  {} clientSoureMacBytes {} inPortStringBytes {} vlan {}",
+         log.trace("Length: interfaceIdBytes  {} clientSoureMacBytes {} inPortStringBytes {} vlan {}",
                    interfaceIdBytes.length, clientSoureMacBytes.length, inPortStringBytes.length,
                    vlanIdBytes.length);
          System.arraycopy(clientSoureMacBytes, 0, interfaceIdBytes, 0, clientSoureMacBytes.length);
@@ -1068,19 +1066,19 @@
         }
         MacAddress relayAgentMac = clientInterface.mac();
         if (relayAgentMac == null) {
-            log.warn("Can not get interface mac, abort packet..");
+            log.warn("Can not get client interface mac, abort packet..");
             return null;
         }
         etherReply.setSourceMACAddress(relayAgentMac);
 
         // find destMac
-        MacAddress clientMac = null;
+        MacAddress clientMac;
         Ip6Address peerAddress = Ip6Address.valueOf(dhcp6Relay.getPeerAddress());
         Set<Host> clients = hostService.getHostsByIp(peerAddress);
         if (clients.isEmpty()) {
-            log.warn("There's no host found for this address {}",
+            log.trace("There's no host found for this address {}",
                     HexString.toHexString(dhcp6Relay.getPeerAddress(), ":"));
-            log.warn("Let's look up interfaceId {}", HexString.toHexString(peerMac.toBytes(), ":"));
+            log.trace("Let's look up interfaceId {}", HexString.toHexString(peerMac.toBytes(), ":"));
             clientMac = peerMac;
         } else {
             clientMac = clients.iterator().next().mac();
@@ -1088,7 +1086,7 @@
                 log.warn("No client mac address found, abort packet...");
                 return null;
             }
-            log.warn("Client mac address found from getHostByIp");
+            log.trace("Client mac address found from getHostByIp");
 
         }
         etherReply.setDestinationMACAddress(clientMac);
@@ -1577,7 +1575,7 @@
         nextHopIp = gwHost.ipAddresses()
                 .stream()
                 .filter(IpAddress::isIp6)
-                .filter(ip6 -> ip6.isLinkLocal())
+                .filter(IpAddress::isLinkLocal)
                 .map(IpAddress::getIp6Address)
                 .findFirst()
                 .orElse(null);
