From 87f514006bc79fa977a9924039e0f5b8e70a9e6b Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Thu, 11 Apr 2019 09:49:42 +0800 Subject: Change logging from FlexLogger to SLF4J Replace the FlexLogger with SLF4J in forward plugins. Change-Id: I20077f1a400cd1a28b4b32f877d20d5628af881c Issue-ID: POLICY-1346 Signed-off-by: Lianhao Lu --- .../forwarding/apex/pdp/ApexPdpPolicyForwarder.java | 12 +++++++----- .../forwarding/file/FilePolicyForwarder.java | 11 ++++++----- .../forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java | 16 +++++++++------- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'plugins') diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java index 98f4d939..8b8528fb 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Intel Corp. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +28,6 @@ import java.util.Collection; import org.apache.commons.io.IOUtils; import org.onap.policy.apex.core.deployment.EngineServiceFacade; import org.onap.policy.apex.model.basicmodel.concepts.ApexException; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.PolicyForwardingException; @@ -36,6 +35,9 @@ import org.onap.policy.distribution.forwarding.xacml.pdp.XacmlPdpPolicyForwarder import org.onap.policy.distribution.model.Policy; import org.onap.policy.distribution.model.PolicyAsString; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies to * apex-pdp. @@ -44,7 +46,7 @@ import org.onap.policy.distribution.model.PolicyAsString; */ public class ApexPdpPolicyForwarder implements PolicyForwarder { - private static final Logger LOGGER = FlexLogger.getLogger(XacmlPdpPolicyForwarder.class); + private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpPolicyForwarder.class); private static final String POLICY_TYPE = "APEX"; private ApexPdpPolicyForwarderParameterGroup apexForwarderParameters; @@ -100,8 +102,8 @@ public class ApexPdpPolicyForwarder implements PolicyForwarder { engineServiceFacade.deployModel(apexPolicy.getPolicyName(), policyInputStream, apexForwarderParameters.isIgnoreConflicts(), apexForwarderParameters.isForceUpdate()); - LOGGER.debug("Sucessfully forwarded the policy to apex-pdp egine at " - + apexForwarderParameters.getHostname() + ":" + apexForwarderParameters.getPort()); + LOGGER.debug("Sucessfully forwarded the policy to apex-pdp egine at {}:{}", + apexForwarderParameters.getHostname(), apexForwarderParameters.getPort()); } catch (final ApexException | IOException exp) { final String message = "Error sending policy to apex-pdp engine at" + apexForwarderParameters.getHostname() diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java index 98d9af4e..4115bff3 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java @@ -29,21 +29,22 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.PolicyForwardingException; import org.onap.policy.distribution.model.OptimizationPolicy; import org.onap.policy.distribution.model.Policy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This class provides an implementation of {@link PolicyForwarder} interface for forwarding the given policies to * a file directory. */ public class FilePolicyForwarder implements PolicyForwarder { - private static final Logger LOGGER = FlexLogger.getLogger(FilePolicyForwarder.class); + private static final Logger LOGGER = LoggerFactory.getLogger(FilePolicyForwarder.class); private FilePolicyForwarderParameterGroup fileForwarderParameters; /** @@ -58,7 +59,7 @@ public class FilePolicyForwarder implements PolicyForwarder { Files.createDirectories(path); } } catch (final InvalidPathException | IOException e) { - LOGGER.error(e.toString()); + LOGGER.error("Configuring FilePolicyForwarder failed!", e); } } @@ -112,7 +113,7 @@ public class FilePolicyForwarder implements PolicyForwarder { writer.write("riskType: " + pol.getRiskType()); } writer.close(); - LOGGER.debug("Sucessfully forwarded the policy to store into file: " + path.toString()); + LOGGER.debug("Sucessfully forwarded the policy to store into file {}.", path); } catch (final InvalidPathException | IOException exp) { final String message = "Error sending policy to file under path:" + fileForwarderParameters.getPath(); LOGGER.error(message, exp); diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java index 972e5abe..6db56653 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/xacml/pdp/XacmlPdpPolicyForwarder.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Intel Corp. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +32,14 @@ import org.onap.policy.api.PolicyParameters; import org.onap.policy.api.PushPolicyParameters; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.xacml.pdp.adapters.XacmlPdpOptimizationPolicyAdapter; import org.onap.policy.distribution.model.OptimizationPolicy; import org.onap.policy.distribution.model.Policy; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; /** @@ -45,7 +47,7 @@ import org.springframework.http.HttpStatus; */ public class XacmlPdpPolicyForwarder implements PolicyForwarder { - private static final Logger LOGGER = FlexLogger.getLogger(XacmlPdpPolicyForwarder.class); + private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpPolicyForwarder.class); private static final String BASE_PATH = "pdp/api/"; private XacmlPdpPolicyForwarderParameterGroup configurationParameters = null; @@ -62,8 +64,8 @@ public class XacmlPdpPolicyForwarder implements PolicyForwarder { XacmlPdpPolicyAdapter policyAdapter = getXacmlPdpPolicyAdapter(policy); if (policyAdapter == null) { - LOGGER.error("Cannot forward policy " + policy + ". Unsupported policy type " - + policy.getClass().getSimpleName()); + LOGGER.error("Cannot forward policy {}. Unsupported policy type {}", + policy, policy.getClass().getSimpleName()); return; } @@ -103,8 +105,8 @@ public class XacmlPdpPolicyForwarder implements PolicyForwarder { if (response.getStatus() != HttpStatus.OK.value()) { LOGGER.error( - "Invocation of method " + method + " failed for policy " + policyName + ". Response status: " - + response.getStatus() + ", Response status info: " + response.getStatusInfo()); + "Invocation of method {} failed for policy {}. Response status: {}, Response status info: {}", + method, policyName, response.getStatus(), response.getStatusInfo()); return false; } } catch (KeyManagementException | NoSuchAlgorithmException | ClassNotFoundException exception) { -- cgit 1.2.3-korg