diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
index f065934..0176aca 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
@@ -138,7 +138,7 @@
     public GenericResourceApiProvider(DataBroker dataBroker2,
                                       NotificationPublishService notificationPublishService,
             RpcProviderRegistry rpcProviderRegistry) {
-        this.log.info( "Creating provider for " + appName );
+        log.info( "Creating provider for {}", appName);
         executor = Executors.newFixedThreadPool(1);
         dataBroker = dataBroker2;
         notificationService = notificationPublishService;
@@ -148,7 +148,7 @@
     }
 
     public void initialize(){
-        log.info( "Initializing provider for " + appName );
+        log.info("Initializing provider for {}", appName);
         // Create the top level containers
         createContainers();
         try {
@@ -158,7 +158,7 @@
         }
         rpcRegistration = rpcRegistry.addRpcImplementation(GENERICRESOURCEAPIService.class, this);
 
-        log.info( "Initialization complete for " + appName );
+        log.info("Initialization complete for {}", appName);
     }
 
 
@@ -169,10 +169,10 @@
 
     @Override
     public void close() throws Exception {
-        log.info( "Closing provider for " + appName );
+        log.info("Closing provider for {}", appName);
         executor.shutdown();
         rpcRegistration.close();
-        log.info( "Successfully closed provider for " + appName );
+        log.info("Successfully closed provider for {}", appName);
     }
 
     private static class Iso8601Util
@@ -191,22 +191,21 @@
     public void setDataBroker(DataBroker dataBroker) {
         this.dataBroker = dataBroker;
         if( log.isDebugEnabled() ){
-            log.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." );
+            log.debug("DataBroker set to {}", (dataBroker==null?"null":"non-null"));
         }
     }
 
-    public void setNotificationService(
-            NotificationPublishService notificationService) {
+    public void setNotificationService(NotificationPublishService notificationService) {
         this.notificationService = notificationService;
         if( log.isDebugEnabled() ){
-            log.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." );
+            log.debug("Notification Service set to {}", (notificationService==null?"null":"non-null"));
         }
     }
 
     public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
         this.rpcRegistry = rpcRegistry;
         if( log.isDebugEnabled() ){
-            log.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." );
+            log.debug("RpcRegistry set to {}", (rpcRegistry==null?"null":"non-null"));
         }
     }
 
@@ -229,11 +228,10 @@
         try {
             CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
             checkedFuture.get();
-            log.info("Create Containers succeeded!: ");
+            log.info("Create containers succeeded!");
 
         } catch (InterruptedException | ExecutionException e) {
-            log.error("Create Containers Failed: " + e);
-            e.printStackTrace();
+            log.error("Create containers failed: ", e);
         }
     }
 
@@ -290,16 +288,16 @@
                     serviceStatusBuilder.setRpcAction(RpcAction.Delete);
                     break;
                 default:
-                    log.error("Unknown SvcAction: " + requestHeader.getSvcAction() );
+                    log.error("Unknown SvcAction: {}", requestHeader.getSvcAction() );
                     break;
-            };
+            }
         }
     }
 
     private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder)
     {
         // default to config
-        getServiceData(siid,serviceDataBuilder,LogicalDatastoreType.CONFIGURATION);
+        getServiceData(siid,serviceDataBuilder, LogicalDatastoreType.CONFIGURATION);
     }
 
 
@@ -314,13 +312,13 @@
         try {
             data = (Optional<Service>) readTx.read(type, serviceInstanceIdentifier).get();
         } catch (InterruptedException | ExecutionException e) {
-            log.error("Caught Exception reading MD-SAL ("+type+") for ["+siid+"] " ,e);
+            log.error("Caught Exception reading MD-SAL ({}) data for [{}] ", type, siid, e);
         }
 
         if (data != null && data.isPresent()) {
             ServiceData serviceData = data.get().getServiceData();
             if (serviceData != null) {
-                log.info("Read MD-SAL ("+type+") data for ["+siid+"] ServiceData: " + serviceData);
+                log.info("Read MD-SAL ({}) data for [{}] ServiceData: {}", type, siid, serviceData);
                 serviceDataBuilder.setSdncRequestHeader(serviceData.getSdncRequestHeader());
                 serviceDataBuilder.setRequestInformation(serviceData.getRequestInformation());
                 serviceDataBuilder.setServiceInformation(serviceData.getServiceInformation());
@@ -333,49 +331,49 @@
                 serviceDataBuilder.setConsumedAllottedResources(serviceData.getConsumedAllottedResources());
                 // service-instance-id needs to be set
             } else {
-                log.info("No service-data found in MD-SAL ("+type+") for ["+siid+"] ");
+                log.info("No service-data found in MD-SAL ({}) for [{}]", type, siid);
             }
         } else {
-            log.info("No data found in MD-SAL ("+type+") for ["+siid+"] ");
+            log.info("No data found in MD-SAL ({}) for [{}]", type, siid);
         }
     }
 
     private void getPreloadData(String vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder)
     {
         // default to config
-        getPreloadData(vnf_name, vnf_type ,preloadDataBuilder,LogicalDatastoreType.CONFIGURATION);
+        getPreloadData(vnf_name, vnf_type ,preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
     }
 
     private void getPreloadData(String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type)
     {
         // See if any data exists yet for this name/type, if so grab it.
-        InstanceIdentifier preloadInstanceIdentifier =
-                InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class)
+        InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class)
                 .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build();
         ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
         Optional<VnfPreloadList> data = null;
         try {
             data = (Optional<VnfPreloadList>) readTx.read(type, preloadInstanceIdentifier).get();
         } catch (InterruptedException | ExecutionException e) {
-            log.error("Caught Exception reading MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] " ,e);
+            log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type, e);
         }
 
         if (data != null && data.isPresent()) {
             PreloadData preloadData = data.get().getPreloadData();
             if (preloadData != null) {
-                log.info("Read MD-SAL ("+type+") data for ["+preload_name+","+preload_type+"] PreloadData: " + preloadData);
+                log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}",
+                    type, preload_name, preload_type, preloadData);
                 preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation());
                 preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation());
                 preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
             } else {
-                log.info("No preload-data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+                log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type);
             }
         } else {
-            log.info("No data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+            log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type);
         }
     }
 
-    private void SaveService (final Service entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
+    private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceBuilder =
                 InstanceIdentifier.<Services>builder(Services.class)
@@ -409,7 +407,7 @@
         }
     }
 
-    private void DeleteService(final Service entry, LogicalDatastoreType storeType) throws IllegalStateException {
+    private void deleteService(final Service entry, LogicalDatastoreType storeType) throws IllegalStateException {
         // Each entry will be identifiable by a unique key, we have to create
         // that identifier
         InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceListIdBuilder = InstanceIdentifier.<Services> builder(Services.class).child(Service.class, entry.getKey());
@@ -438,7 +436,7 @@
         }
     }
 
-    private void SavePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{
+    private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{
 
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier.InstanceIdentifierBuilder<VnfPreloadList> vnfPreloadListBuilder =
@@ -481,7 +479,7 @@
 		ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
 		Properties parms = new Properties();
 
-		log.info( SVC_OPERATION +" called." );
+		log.info("{} called.",SVC_OPERATION);
 		// create a new response object
 		ServiceTopologyOperationOutputBuilder responseBuilder = new ServiceTopologyOperationOutputBuilder();
 
@@ -490,7 +488,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+			log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -526,11 +524,11 @@
         //  uses service-response-information;
         */
 
-		log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+		log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input);
 		ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(input);
 		GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
 
-		log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+siid+"] operational-data: " + operDataBuilder.build());
+		log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build());
 		GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder);
 
 		// Call SLI sync method
@@ -555,7 +553,7 @@
 				}
 				catch (Exception e)
 				{
-					log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+					log.error("Caught exception executing service logic for {} ", SVC_OPERATION, e);
 					errorMessage = e.getMessage();
 					errorCode = "500";
 				}
@@ -594,11 +592,11 @@
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
 			try {
-				SaveService (serviceBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+				saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
 			} catch (Exception e) {
-				log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+				log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			}
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<ServiceTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -607,14 +605,14 @@
 		// Got success from SLI
 		try {
 			serviceData = serviceDataBuilder.build();
-			log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+			log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
 			// service object
 			ServiceBuilder serviceBuilder = new ServiceBuilder();
 			serviceBuilder.setServiceData(serviceData);
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-			SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+			saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -622,8 +620,8 @@
 				if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete))
 				{
 					log.info("Delete from both CONFIGURATION and OPERATIONAL tree.");
-	                DeleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL);
-	                DeleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION);
+	                deleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL);
+	                deleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION);
 				}
 			}
 
@@ -633,11 +631,11 @@
             responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
 		} catch (Exception e) {
-			log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+			log.error("Caught Exception updating MD-SAL for {} [{}] \n",SVC_OPERATION, siid, e);
 			responseBuilder.setResponseCode("500");
 			responseBuilder.setResponseMessage(e.toString());
 			responseBuilder.setAckFinalIndicator("Y");
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<ServiceTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -650,8 +648,8 @@
 		{
 			responseBuilder.setResponseMessage(errorMessage);
 		}
-		log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-		log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+		log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+		log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 		RpcResult<ServiceTopologyOperationOutput> rpcResult =
             RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -667,7 +665,7 @@
 		ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
 		Properties parms = new Properties();
 
-		log.info( SVC_OPERATION +" called." );
+		log.info("{} called.", SVC_OPERATION);
 		// create a new response object
 		VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
 
@@ -676,7 +674,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+			log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -697,7 +695,7 @@
                 input.getVnfInformation().getVnfId() == null ||
                     input.getVnfInformation().getVnfId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty vnf-id");
+			log.debug("exiting {} because of null or empty vnf-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -755,11 +753,11 @@
         //   uses vnf-configuration-information;
         //   uses oper-status;
 
-		log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+		log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input);
 		VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input);
 		GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
 
-		log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+siid+"] operational-data: " + operDataBuilder.build());
+		log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build());
 		GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder);
 
         /*
@@ -789,7 +787,7 @@
 				}
 				catch (Exception e)
 				{
-					log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+					log.error("Caught exception executing service logic for {} ", SVC_OPERATION, e);
 					errorMessage = e.getMessage();
 					errorCode = "500";
 				}
@@ -827,7 +825,7 @@
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
 			try {
-				SaveService (serviceBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+				saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
 				if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 				{
 					// Only update operational tree on activate or delete
@@ -835,13 +833,13 @@
 							input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
 					{
 						log.info("Updating OPERATIONAL tree.");
-						SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+						saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 					}
 				}
 			} catch (Exception e) {
-				log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+				log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			}
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<VnfTopologyOperationOutput> rpcResult =
 			    RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			// return error
@@ -851,14 +849,14 @@
 		// Got success from SLI
 		try {
 			serviceData = serviceDataBuilder.build();
-			log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+			log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
 			// service object
 			ServiceBuilder serviceBuilder = new ServiceBuilder();
 			serviceBuilder.setServiceData(serviceData);
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-			SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+			saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -866,7 +864,7 @@
 				if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
 				{
 					log.info("Updating OPERATIONAL tree.");
-					SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+					saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 				}
 			}
 
@@ -876,11 +874,11 @@
             responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
 		} catch (Exception e) {
-			log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+			log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			responseBuilder.setResponseCode("500");
 			responseBuilder.setResponseMessage(e.toString());
 			responseBuilder.setAckFinalIndicator("Y");
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<VnfTopologyOperationOutput> rpcResult =
 			    RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -893,8 +891,8 @@
 		{
 			responseBuilder.setResponseMessage(errorMessage);
 		}
-		log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-		log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+		log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+		log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 		RpcResult<VnfTopologyOperationOutput> rpcResult =
 		    RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -911,7 +909,7 @@
         ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
         Properties parms = new Properties();
 
-        log.info( SVC_OPERATION +" called." );
+        log.info("{} called.", SVC_OPERATION);
         // create a new response object
         VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
 
@@ -920,7 +918,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-            log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+            log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
             responseBuilder.setAckFinalIndicator("Y");
@@ -934,7 +932,7 @@
                 input.getVnfInformation().getVnfId() == null ||
                     input.getVnfInformation().getVnfId().length() == 0)
         {
-            log.debug("exiting " +SVC_OPERATION+ " because of null or empty vnf-id");
+            log.debug("exiting {} because of null or empty vnf-id", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
             responseBuilder.setAckFinalIndicator("Y");
@@ -947,7 +945,7 @@
                 input.getVfModuleInformation().getVfModuleId() == null ||
                     input.getVfModuleInformation().getVfModuleId().length() == 0)
         {
-            log.debug("exiting " +SVC_OPERATION+ " because of null or empty vf-module-id");
+            log.debug("exiting {} because of null or empty vf-module-id", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("invalid input, vf-module-id is null or empty");
             responseBuilder.setAckFinalIndicator("Y");
@@ -1010,11 +1008,11 @@
         //   uses vnf-configuration-information;
         //   uses oper-status;
 
-        log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+        log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input);
         VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input);
         GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
 
-        log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+siid+"] operational-data: " + operDataBuilder.build());
+        log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build());
         GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder);
 
         /*
@@ -1081,11 +1079,11 @@
             serviceBuilder.setServiceInstanceId(siid);
             serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
             try {
-                SaveService (serviceBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+                saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
             } catch (Exception e) {
-                log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+                log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
             }
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+            log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
             RpcResult<VfModuleTopologyOperationOutput> rpcResult =
                     RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
             // return error
@@ -1095,7 +1093,7 @@
         // Got success from SLI
         try {
             serviceData = serviceDataBuilder.build();
-            log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+            log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
             // service object
             ServiceBuilder serviceBuilder = new ServiceBuilder();
@@ -1103,7 +1101,7 @@
             //serviceBuilder.setServiceInstanceId(serviceData.getServiceTopology().getServiceTopologyIdentifier().getServiceInstanceId());
             serviceBuilder.setServiceInstanceId(siid);
             serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-            SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+            saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -1112,7 +1110,7 @@
 						input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
 				{
 					log.info("Updating OPERATIONAL tree.");
-					SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+					saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 				}
 			}
 
@@ -1122,11 +1120,11 @@
             responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
         } catch (Exception e) {
-            log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+            log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
             responseBuilder.setResponseCode("500");
             responseBuilder.setResponseMessage(e.toString());
             responseBuilder.setAckFinalIndicator("Y");
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+            log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
             RpcResult<VfModuleTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
             return Futures.immediateFuture(rpcResult);
@@ -1139,8 +1137,8 @@
         {
             responseBuilder.setResponseMessage(errorMessage);
         }
-        log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-        log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+        log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+        log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
         RpcResult<VfModuleTopologyOperationOutput> rpcResult =
             RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1157,7 +1155,7 @@
 		ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
 		Properties parms = new Properties();
 
-		log.info( SVC_OPERATION +" called." );
+		log.info("{} called.", SVC_OPERATION );
 		// create a new response object
 		NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder();
 
@@ -1166,7 +1164,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+			log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1188,7 +1186,7 @@
         ServiceData sd = serviceDataBuilder.build();
         if (sd == null || sd.getServiceLevelOperStatus() == null)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because the service-instance does not have any service data in SDNC");
+			log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1222,7 +1220,7 @@
         }
         */
 
-		log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+		log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input);
 		NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder(input);
 		GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
 
@@ -1250,7 +1248,7 @@
 				}
 				catch (Exception e)
 				{
-					log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+					log.error("Caught exception executing service logic for {}", SVC_OPERATION, e);
 					errorMessage = e.getMessage();
 					errorCode = "500";
 				}
@@ -1282,7 +1280,7 @@
 			responseBuilder.setResponseMessage(errorMessage);
 			responseBuilder.setAckFinalIndicator(ackFinal);
 
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 			RpcResult<NetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1293,14 +1291,14 @@
 		try {
 
 			serviceData = serviceDataBuilder.build();
-			log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+			log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
 			// service object
 			ServiceBuilder serviceBuilder = new ServiceBuilder();
 			serviceBuilder.setServiceData(serviceData);
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-			SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+			saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -1308,7 +1306,7 @@
 				if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
                 {
 					log.info("Updating OPERATIONAL tree.");
-					SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+					saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 				}
 			}
 
@@ -1323,11 +1321,11 @@
 			responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
 		} catch (IllegalStateException e) {
-			log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+			log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			responseBuilder.setResponseCode("500");
 			responseBuilder.setResponseMessage(e.toString());
 			responseBuilder.setAckFinalIndicator("Y");
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<NetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -1340,8 +1338,8 @@
 		{
 			responseBuilder.setResponseMessage(errorMessage);
 		}
-		log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-		log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+		log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+		log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 		RpcResult<NetworkTopologyOperationOutput> rpcResult =
             RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1357,7 +1355,7 @@
 		ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
 		Properties parms = new Properties();
 
-		log.info( SVC_OPERATION +" called." );
+		log.info("{} called.", SVC_OPERATION);
 		// create a new response object
 		ContrailRouteTopologyOperationOutputBuilder responseBuilder = new ContrailRouteTopologyOperationOutputBuilder();
 
@@ -1366,7 +1364,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+			log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1388,7 +1386,7 @@
         ServiceData sd = serviceDataBuilder.build();
         if (sd == null || sd.getServiceLevelOperStatus() == null)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because the service-instance does not have any service data in SDNC");
+			log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1425,7 +1423,7 @@
 				}
 				catch (Exception e)
 				{
-					log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+					log.error("Caught exception executing service logic for {}", SVC_OPERATION, e);
 					errorMessage = e.getMessage();
 					errorCode = "500";
 				}
@@ -1457,7 +1455,7 @@
 			responseBuilder.setResponseMessage(errorMessage);
 			responseBuilder.setAckFinalIndicator(ackFinal);
 
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 			RpcResult<ContrailRouteTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1468,14 +1466,14 @@
 		try {
 
 			serviceData = serviceDataBuilder.build();
-			log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+			log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
 			// service object
 			ServiceBuilder serviceBuilder = new ServiceBuilder();
 			serviceBuilder.setServiceData(serviceData);
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-			SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+			saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -1484,7 +1482,7 @@
 						input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
 				{
 					log.info("Updating OPERATIONAL tree.");
-					SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+					saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 				}
 			}
 
@@ -1499,11 +1497,11 @@
 			responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
 		} catch (IllegalStateException e) {
-			log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+			log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			responseBuilder.setResponseCode("500");
 			responseBuilder.setResponseMessage(e.toString());
 			responseBuilder.setAckFinalIndicator("Y");
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<ContrailRouteTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -1516,8 +1514,8 @@
 		{
 			responseBuilder.setResponseMessage(errorMessage);
 		}
-		log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-		log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+		log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+		log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 		RpcResult<ContrailRouteTopologyOperationOutput> rpcResult =
             RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1533,7 +1531,7 @@
 		ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
 		Properties parms = new Properties();
 
-		log.info( SVC_OPERATION +" called." );
+		log.info("{} called.", SVC_OPERATION);
 		// create a new response object
 		SecurityZoneTopologyOperationOutputBuilder responseBuilder = new SecurityZoneTopologyOperationOutputBuilder();
 
@@ -1542,7 +1540,7 @@
                 input.getServiceInformation().getServiceInstanceId() == null ||
                     input.getServiceInformation().getServiceInstanceId().length() == 0)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because of null or empty service-instance-id");
+			log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1564,7 +1562,7 @@
         ServiceData sd = serviceDataBuilder.build();
         if (sd == null || sd.getServiceLevelOperStatus() == null)
         {
-			log.debug("exiting " +SVC_OPERATION+ " because the service-instance does not have any service data in SDNC");
+			log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION);
 			responseBuilder.setResponseCode("404");
 			responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC");
 			responseBuilder.setAckFinalIndicator("Y");
@@ -1573,7 +1571,7 @@
 			return Futures.immediateFuture(rpcResult);
 		}
 
-		log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+		log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input);
 		SecurityZoneTopologyOperationInputBuilder inputBuilder = new SecurityZoneTopologyOperationInputBuilder(input);
 		GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
 
@@ -1601,7 +1599,7 @@
 				}
 				catch (Exception e)
 				{
-					log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+					log.error("Caught exception executing service logic for {}", SVC_OPERATION, e);
 					errorMessage = e.getMessage();
 					errorCode = "500";
 				}
@@ -1633,7 +1631,7 @@
 			responseBuilder.setResponseMessage(errorMessage);
 			responseBuilder.setAckFinalIndicator(ackFinal);
 
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 			RpcResult<SecurityZoneTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1644,14 +1642,14 @@
 		try {
 
 			serviceData = serviceDataBuilder.build();
-			log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+			log.info("Updating MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData);
 
 			// service object
 			ServiceBuilder serviceBuilder = new ServiceBuilder();
 			serviceBuilder.setServiceData(serviceData);
 			serviceBuilder.setServiceInstanceId(siid);
 			serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
-			SaveService (serviceBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
+			saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
 
 			if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
 			{
@@ -1660,7 +1658,7 @@
 						input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
 				{
 					log.info("Updating OPERATIONAL tree.");
-					SaveService (serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+					saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
 				}
 			}
 
@@ -1675,11 +1673,11 @@
 			responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
 
 		} catch (IllegalStateException e) {
-			log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+			log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e);
 			responseBuilder.setResponseCode("500");
 			responseBuilder.setResponseMessage(e.toString());
 			responseBuilder.setAckFinalIndicator("Y");
-			log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+			log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 			RpcResult<SecurityZoneTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
 			return Futures.immediateFuture(rpcResult);
@@ -1692,8 +1690,8 @@
 		{
 			responseBuilder.setResponseMessage(errorMessage);
 		}
-		log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
-		log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+		log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid);
+		log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build());
 
 		RpcResult<SecurityZoneTopologyOperationOutput> rpcResult =
             RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1705,10 +1703,10 @@
             PreloadVnfTopologyOperationInput input) {
 
         final String SVC_OPERATION = "preload-vnf-topology-operation";
-        PreloadData preloadData = null;
+        PreloadData preloadData;
         Properties parms = new Properties();
 
-        log.info( SVC_OPERATION +" called." );
+        log.info("{} called.", SVC_OPERATION);
         // create a new response object
         PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder();
 
@@ -1717,7 +1715,7 @@
 
         if(input == null || input.getVnfTopologyInformation() == null ||
             input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null) {
-                log.debug("exiting " +SVC_OPERATION+ " because of null input");
+                log.debug("exiting {} because of null input", SVC_OPERATION);
                 responseBuilder.setResponseCode("403");
                 responseBuilder.setResponseMessage("invalid input: input is null");
                 responseBuilder.setAckFinalIndicator("Y");
@@ -1732,7 +1730,7 @@
 
         // Make sure we have a preload_name and preload_type
         if(preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0 ) {
-            log.debug("exiting "+ SVC_OPERATION + " vnf-name or vnf-type is null or empty");
+            log.debug("exiting {} vnf-name or vnf-type is null or empty", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("invalid input: vnf-name or vnf-type is null or empty");
             responseBuilder.setAckFinalIndicator("Y");
@@ -1765,10 +1763,11 @@
         //   uses network-topology-information;
         //   uses oper-status;
 
-        log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
+        log.info("Adding INPUT data for {} [{},{}] input: {}", SVC_OPERATION, preload_name, preload_type, input);
         PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input);
         GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-        log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+        log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}",
+            SVC_OPERATION, preload_name, preload_type, operDataBuilder.build());
         GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder);
 
         // Call SLI sync method
@@ -1793,7 +1792,7 @@
                 }
                 catch (Exception e)
                 {
-                    log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+                    log.error("Caught exception executing service logic for {}", SVC_OPERATION, e);
                     errorMessage = e.getMessage();
                     errorCode = "500";
                 }
@@ -1828,11 +1827,13 @@
             preloadVnfListBuilder.setVnfName(preload_name);
             preloadVnfListBuilder.setVnfType(preload_type);
             preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+            log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'",
+                SVC_OPERATION, preload_name, preload_type, errorCode, errorMessage);
             try {
-                SavePreloadList (preloadVnfListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+                savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
             } catch (Exception e) {
-                log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+                log.error("Caught Exception updating MD-SAL for {} [{},{}] \n",
+                    SVC_OPERATION, preload_name, preload_type, e);
             }
             log.debug("Sending Success rpc result due to external error");
             RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
@@ -1843,7 +1844,8 @@
         // Got success from SLI
         try {
             preloadData = preloadDataBuilder.build();
-            log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + preloadData);
+            log.info("Updating MD-SAL for {} [{},{}] preloadData: {}",
+                SVC_OPERATION, preload_name, preload_type, preloadData);
             // svc-configuration-list
             VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
             preloadVnfListBuilder.setVnfName(preload_name);
@@ -1851,15 +1853,17 @@
             preloadVnfListBuilder.setPreloadData(preloadData);
 
             // merge flag sets to false to allow it to be overwritten (not appended)
-            SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+            savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
             log.info("Updating OPERATIONAL tree.");
-            SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+            savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
         } catch (Exception e) {
-            log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+            log.error("Caught Exception updating MD-SAL for {} [{},{}] \n",
+                SVC_OPERATION, preload_name, preload_type, e);
             responseBuilder.setResponseCode("500");
             responseBuilder.setResponseMessage(e.toString());
             responseBuilder.setAckFinalIndicator("Y");
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+            log.error("Returned FAILED for {} [{},{}] {}",
+                SVC_OPERATION, preload_name, preload_type, responseBuilder.build());
             RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
             return Futures.immediateFuture(rpcResult);
@@ -1872,8 +1876,8 @@
         {
             responseBuilder.setResponseMessage(errorMessage);
         }
-        log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
-        log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+        log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type);
+        log.info("Returned SUCCESS for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, responseBuilder.build());
 
         RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
@@ -1886,10 +1890,10 @@
             PreloadNetworkTopologyOperationInput input) {
 
         final String SVC_OPERATION = "preload-network-topology-operation";
-        PreloadData preloadData = null;
+        PreloadData preloadData;
         Properties parms = new Properties();
 
-        log.info( SVC_OPERATION +" called." );
+        log.info("{} called.", SVC_OPERATION);
         // create a new response object
         PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder();
 
@@ -1899,7 +1903,7 @@
         if(input == null || input.getNetworkTopologyInformation() == null ||
             input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null) {
 
-            log.debug("exiting " +SVC_OPERATION+ " because of null input");
+            log.debug("exiting {} because of null input", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("input is null");
             responseBuilder.setAckFinalIndicator("Y");
@@ -1914,7 +1918,7 @@
 
         // Make sure we have a preload_name and preload_type
         if(preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0 ) {
-            log.debug("exiting "+SVC_OPERATION+" because of invalid preload-name");
+            log.debug("exiting {} because of invalid preload-name", SVC_OPERATION);
             responseBuilder.setResponseCode("403");
             responseBuilder.setResponseMessage("input, invalid preload-name");
             responseBuilder.setAckFinalIndicator("Y");
@@ -1949,10 +1953,11 @@
         //   uses oper-status;
 
 
-        log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
+        log.info("Adding INPUT data for {} [{},{}] input: {}", SVC_OPERATION, preload_name, preload_type, input);
         PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(input);
         GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-        log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+        log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}",
+            SVC_OPERATION, preload_name, preload_type, operDataBuilder.build());
         GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder);
 
         // Call SLI sync method
@@ -1977,7 +1982,7 @@
                 }
                 catch (Exception e)
                 {
-                    log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+                    log.error("Caught exception executing service logic for {}", SVC_OPERATION, e);
                     errorMessage = e.getMessage();
                     errorCode = "500";
                 }
@@ -2012,11 +2017,13 @@
             preloadVnfListBuilder.setVnfName(preload_name);
             preloadVnfListBuilder.setVnfType(preload_type);
             preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+            log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'",
+                SVC_OPERATION, preload_name, preload_type, errorCode, errorMessage);
             try {
-                SavePreloadList (preloadVnfListBuilder.build(),true,LogicalDatastoreType.CONFIGURATION);
+                savePreloadList(preloadVnfListBuilder.build(),true, LogicalDatastoreType.CONFIGURATION);
             } catch (Exception e) {
-                log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+                log.error("Caught Exception updating MD-SAL for {} [{},{}] \n",
+                    SVC_OPERATION, preload_name, preload_type, e);
 
             }
             log.debug("Sending Success rpc result due to external error");
@@ -2028,7 +2035,8 @@
         // Got success from SLI
         try {
             preloadData = preloadDataBuilder.build();
-            log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + preloadData);
+            log.info("Updating MD-SAL for {} [{},{}] preloadData: {}",
+                SVC_OPERATION, preload_name, preload_type, preloadData);
             // svc-configuration-list
             VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
             preloadVnfListBuilder.setVnfName(preload_name);
@@ -2036,15 +2044,16 @@
             preloadVnfListBuilder.setPreloadData(preloadData);
 
             // merge flag sets to false to allow it to be overwritten (not appended)
-            SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+            savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
             log.info("Updating OPERATIONAL tree.");
-            SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+            savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
         } catch (Exception e) {
             log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
             responseBuilder.setResponseCode("500");
             responseBuilder.setResponseMessage(e.toString());
             responseBuilder.setAckFinalIndicator("Y");
-            log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+            log.error("Returned FAILED for {} [{},{}] {}",
+                SVC_OPERATION, preload_name, preload_type, responseBuilder.build());
             RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
             return Futures.immediateFuture(rpcResult);
@@ -2057,8 +2066,9 @@
         {
             responseBuilder.setResponseMessage(errorMessage);
         }
-        log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
-        log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+        log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type);
+        log.info("Returned SUCCESS for {} [{},{}] {}",
+            SVC_OPERATION, preload_name, preload_type, responseBuilder.build());
 
         RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
