From: Maciej Malewski Date: Fri, 17 Jul 2020 06:31:51 +0000 (+0200) Subject: Upgrade log4j to 2.13.1 and add log4j api 2.13.1. X-Git-Tag: 2.3.0~9 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=d8f4b453be2dd8b188ad4bca11cede52a30e7806;p=optf%2Fcmso.git Upgrade log4j to 2.13.1 and add log4j api 2.13.1. Issue-ID: OPTFRA-752 Signed-off-by: Maciej Malewski Change-Id: Ib39de5e892f00c07c812a8dc8d3ac7d1fca009cf --- diff --git a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java index e3a581d..d8b67bf 100644 --- a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java +++ b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java b/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java index f63701e..2c646d8 100644 --- a/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java +++ b/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-logger/pom.xml b/cmso-logger/pom.xml new file mode 100644 index 0000000..2665690 --- /dev/null +++ b/cmso-logger/pom.xml @@ -0,0 +1,57 @@ + + + + cmso + org.onap.optf.cmso + 2.2.0-SNAPSHOT + + 4.0.0 + + cmso-logger + + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + com.att.eelf + eelf-core + ${eelf.version} + + + org.mockito + mockito-core + + + org.powermock + powermock-module + + + org.powermock + powermock-api-mockito + + + org.powermock + powermock-module-junit4 + + + + + + javax.ws.rs + javax.ws.rs-api + ${javax.version.rs.api} + + + + + \ No newline at end of file diff --git a/cmso-logger/src/main/java/org/onap/logger/Logger.java b/cmso-logger/src/main/java/org/onap/logger/Logger.java new file mode 100644 index 0000000..602def3 --- /dev/null +++ b/cmso-logger/src/main/java/org/onap/logger/Logger.java @@ -0,0 +1,123 @@ +/* + * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.logger; + +import com.att.eelf.configuration.EELFLogger; +import org.apache.logging.log4j.spi.StandardLevel; +import org.onap.observations.ObservationInterface; + +public class Logger { + + private final EELFLogger log; + private final EELFLogger metrics; + private final EELFLogger audit; + private final EELFLogger errors; + private final EELFLogger debug; + + public Logger(EELFLogger log, EELFLogger metrics, EELFLogger audit, EELFLogger errors, EELFLogger debug) { + this.log = log; + this.metrics = metrics; + this.audit = audit; + this.errors = errors; + this.debug = debug; + } + + public void report(ObservationInterface obs, Exception except, String... arguments) { + + if (obs.getAudit()) { + audit.info(obs, except, arguments); + } + if (obs.getMetric()) { + metrics.info(obs, except, arguments); + } + + final StandardLevel standardLevel = obs.getLevel().getStandardLevel(); + + switch (standardLevel) { + case WARN: + errors.warn(obs, arguments); + debug.debug(obs, except, arguments); + break; + case INFO: + log.info(obs, except, arguments); + debug.debug(obs, except, arguments); + break; + case ERROR: + errors.error(obs, arguments); + debug.debug(obs, except, arguments); + break; + case TRACE: + debug.trace(obs, except, arguments); + break; + case DEBUG: + debug.debug(obs, except, arguments); + break; + default: + log.info(obs, except, arguments); + } + + } + + public void report(ObservationInterface obs, String... arguments) { + + if (obs.getAudit()) { + audit.info(obs, arguments); + } + if (obs.getMetric()) { + metrics.info(obs, arguments); + } + + final StandardLevel standardLevel = obs.getLevel().getStandardLevel(); + + switch (standardLevel) { + case WARN: + errors.warn(obs, arguments); + debug.debug(obs, arguments); + break; + case INFO: + log.info(obs, arguments); + debug.debug(obs, arguments); + break; + case ERROR: + errors.error(obs, arguments); + debug.debug(obs, arguments); + break; + case TRACE: + debug.debug(obs, arguments); + break; + case DEBUG: + debug.debug(obs, arguments); + break; + default: + log.info(obs, arguments); + } + } +} diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationInterface.java b/cmso-logger/src/main/java/org/onap/observations/ObservationInterface.java similarity index 81% rename from cmso-service/src/main/java/org/onap/observations/ObservationInterface.java rename to cmso-logger/src/main/java/org/onap/observations/ObservationInterface.java index 0dce93d..bc14f33 100644 --- a/cmso-service/src/main/java/org/onap/observations/ObservationInterface.java +++ b/cmso-logger/src/main/java/org/onap/observations/ObservationInterface.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -26,24 +27,20 @@ package org.onap.observations; -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; - -public interface ObservationInterface extends EELFResolvableErrorEnum { - public Enum getValue(); - - public Level getLevel(); - public String getMessage(); - - public Status getStatus(); - - public String getDomain(); +import com.att.eelf.i18n.EELFResolvableErrorEnum; +import org.apache.logging.log4j.Level; - public String name(); +import static javax.ws.rs.core.Response.Status; - public Boolean getAudit(); +public interface ObservationInterface extends EELFResolvableErrorEnum { - public Boolean getMetric(); + Enum getValue(); + Level getLevel(); + String getMessage(); + Status getStatus(); + String getDomain(); + String name(); + Boolean getAudit(); + Boolean getMetric(); } diff --git a/cmso-optimizer/pom.xml b/cmso-optimizer/pom.xml index bf6e3eb..a899f87 100644 --- a/cmso-optimizer/pom.xml +++ b/cmso-optimizer/pom.xml @@ -158,30 +158,6 @@ org.springframework spring-context-support - - com.att.eelf - eelf-core - ${eelf.version} - - - org.mockito - mockito-core - - - org.powermock - powermock-module - - - org.powermock - powermock-api-mockito - - - org.powermock - powermock-module-junit4 - - - - org.yaml snakeyaml @@ -190,11 +166,6 @@ - - javax.ws.rs - javax.ws.rs-api - 2.1 - @@ -250,6 +221,17 @@ org.onap.aaf.authz aaf-cadi-aaf ${aaf.version} + + + log4j + log4j + + + + + org.onap.optf.cmso + cmso-logger + 2.2.0-SNAPSHOT diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java index e6aa29e..faba1df 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/common/LogMessages.java @@ -34,8 +34,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; -import org.onap.optf.cmso.optimizer.observations.ObservationInterface; +import org.apache.logging.log4j.Level; +import org.onap.observations.ObservationInterface; /** * The Enum LogMessages. diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java index f780390..d2d1cc7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/exceptions/CmsoException.java @@ -30,8 +30,8 @@ import com.att.eelf.i18n.EELFResourceManager; import java.util.ArrayList; import java.util.List; import javax.ws.rs.core.Response.Status; +import org.onap.observations.ObservationInterface; import org.onap.optf.cmso.optimizer.common.CmsoRequestError; -import org.onap.optf.cmso.optimizer.observations.ObservationInterface; /** * The Class CMSException. diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java index 66834fa..e994d18 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Mdc.java @@ -38,10 +38,9 @@ import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY; import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME; import com.att.eelf.utils.Stopwatch; -import java.net.URI; -import java.util.Date; -import java.util.Map; -import java.util.UUID; +import org.onap.observations.ObservationInterface; +import org.onap.optf.cmso.optimizer.observations.MessageHeaders.HeadersEnum; +import org.slf4j.MDC; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientResponseContext; @@ -49,8 +48,10 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response.StatusType; -import org.onap.optf.cmso.optimizer.observations.MessageHeaders.HeadersEnum; -import org.slf4j.MDC; +import java.net.URI; +import java.util.Date; +import java.util.Map; +import java.util.UUID; /** * EELF logging MDC fields not defined in the MDC Configuration (i.e. MDC_ALERT_SEVERITY) diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java index cb36e40..baedf3a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/Observation.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -28,10 +29,10 @@ package org.onap.optf.cmso.optimizer.observations; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Level; +import org.onap.logger.Logger; +import org.onap.observations.ObservationInterface; import org.onap.optf.cmso.optimizer.Application; - /** * The Class Observation. */ @@ -42,88 +43,36 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + private static Logger logger = new Logger(log, metrics, audit, errors, debug); + + /** * Report. * - * @param obs the o - * @param execpt the e + * @param obs the o + * @param except the e * @param arguments the arguments */ // ************************************************************************************************* - public static void report(ObservationInterface obs, Exception execpt, String... arguments) { + public static void report(ObservationInterface obs, Exception except, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, execpt, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, execpt, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.INFO_INT: - log.info(obs, execpt, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.TRACE_INT: - debug.trace(obs, execpt, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, execpt, arguments); - break; - default: - log.info(obs, execpt, arguments); - } + logger.report(obs, except, arguments); Mdc.clearCaller(); } /** * Report. * - * @param obs the o + * @param obs the o * @param arguments the arguments */ public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, arguments); - } - Level levl = obs.getLevel(); - switch (levl.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.INFO_INT: - log.info(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.TRACE_INT: - debug.debug(obs, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, arguments); - break; - default: - log.info(obs, arguments); - } + logger.report(obs, arguments); Mdc.clearCaller(); } + } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java deleted file mode 100644 index 2b4ff58..0000000 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationInterface.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2019 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * - * - * Unless otherwise specified, all documentation contained herein is licensed under the Creative - * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except - * in compliance with the License. You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.optf.cmso.optimizer.observations; - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; - -public interface ObservationInterface extends EELFResolvableErrorEnum { - public Enum getValue(); - - public Level getLevel(); - - public String getMessage(); - - public Status getStatus(); - - public String getDomain(); - - public String name(); - - public Boolean getAudit(); - - public Boolean getMetric(); -} diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java index 60ba2a1..7d8ee69 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/observations/ObservationObject.java @@ -28,8 +28,9 @@ package org.onap.optf.cmso.optimizer.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; +import org.apache.logging.log4j.Level; +import org.onap.observations.ObservationInterface; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; /** diff --git a/cmso-service/pom.xml b/cmso-service/pom.xml index db8d37e..947a995 100644 --- a/cmso-service/pom.xml +++ b/cmso-service/pom.xml @@ -168,30 +168,6 @@ com.fasterxml.jackson.dataformat jackson-dataformat-yaml - - com.att.eelf - eelf-core - ${eelf.version} - - - org.mockito - mockito-core - - - org.powermock - powermock-module - - - org.powermock - powermock-api-mockito - - - org.powermock - powermock-module-junit4 - - - - org.yaml snakeyaml @@ -199,11 +175,6 @@ - - javax.ws.rs - javax.ws.rs-api - 2.1 - @@ -263,8 +234,19 @@ org.onap.aaf.authz aaf-cadi-aaf ${aaf.version} + + + log4j + log4j + + - + + org.onap.optf.cmso + cmso-logger + 2.2.0-SNAPSHOT + + cmso-service diff --git a/cmso-service/src/main/java/org/onap/observations/Observation.java b/cmso-service/src/main/java/org/onap/observations/Observation.java index 3d2d176..a097345 100644 --- a/cmso-service/src/main/java/org/onap/observations/Observation.java +++ b/cmso-service/src/main/java/org/onap/observations/Observation.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -28,7 +29,7 @@ package org.onap.observations; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Level; +import org.onap.logger.Logger; import org.onap.optf.cmso.Application; @@ -42,47 +43,21 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + private static Logger logger = new Logger(log, metrics, audit, errors, debug); + /** * Report. * * @param obs the o - * @param execpt the e + * @param except the e * @param arguments the arguments */ // ************************************************************************************************* - public static void report(ObservationInterface obs, Exception execpt, String... arguments) { - Mdc.setCaller(4); - Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, execpt, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, execpt, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.INFO_INT: - log.info(obs, execpt, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.TRACE_INT: - debug.trace(obs, execpt, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, execpt, arguments); - break; - default: - log.info(obs, execpt, arguments); - } - Mdc.clearCaller(); + public static void report(ObservationInterface obs, Exception except, String... arguments) { + Mdc.setCaller(4); + Mdc.setObservation(obs); + logger.report(obs, except, arguments); + Mdc.clearCaller(); } /** @@ -94,35 +69,7 @@ public class Observation { public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, arguments); - } - Level levl = obs.getLevel(); - switch (levl.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.INFO_INT: - log.info(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.TRACE_INT: - debug.debug(obs, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, arguments); - break; - default: - log.info(obs, arguments); - } + logger.report(obs, arguments); Mdc.clearCaller(); } diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java index f1c1277..9ed1d84 100644 --- a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java @@ -28,8 +28,9 @@ package org.onap.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; +import org.apache.logging.log4j.Level; + import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; /** diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/DomainsEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/DomainsEnum.java index cd6af4c..63e2b4a 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/DomainsEnum.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/DomainsEnum.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java index 3fd6cc8..6b6b544 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/LogMessages.java @@ -32,7 +32,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.onap.observations.ObservationInterface; /** diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/DispatchedOptimizerList.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/DispatchedOptimizerList.java index 871e831..c834614 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/DispatchedOptimizerList.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/DispatchedOptimizerList.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmApprovalStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmApprovalStatusEnum.java index 9b004f9..7ae9df9 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmApprovalStatusEnum.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmApprovalStatusEnum.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmAsset.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmAsset.java index ac2d9b8..0802ec1 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmAsset.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmAsset.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmChangeInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmChangeInfo.java index 03b031a..d6231e0 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmChangeInfo.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmChangeInfo.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmStatusEnum.java index dd480b0..0bbcc92 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmStatusEnum.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/bean/TmStatusEnum.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfChangeManagementResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfChangeManagementResponse.java index cdf47f5..e2266b5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfChangeManagementResponse.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfChangeManagementResponse.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfCmResponse200.java b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfCmResponse200.java index 65f2bcc..72b082f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfCmResponse200.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfCmResponse200.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoRequestReferences.java b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoRequestReferences.java index 56743c3..334cc93 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoRequestReferences.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoRequestReferences.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoResponse.java index 1876c93..c565390 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoResponse.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfMsoResponse.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfVidCmResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfVidCmResponse.java index 395d99d..542c898 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfVidCmResponse.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/wf/bean/WfVidCmResponse.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cmso-ticketmgt/pom.xml b/cmso-ticketmgt/pom.xml index 7ba9a83..6c68abb 100644 --- a/cmso-ticketmgt/pom.xml +++ b/cmso-ticketmgt/pom.xml @@ -159,37 +159,8 @@ - - com.att.eelf - eelf-core - ${eelf.version} - - - org.mockito - mockito-core - - - org.powermock - powermock-module - - - org.powermock - powermock-api-mockito - - - org.powermock - powermock-module-junit4 - - - - - - javax.ws.rs - javax.ws.rs-api - 2.1 - @@ -249,6 +220,17 @@ org.onap.aaf.authz aaf-cadi-aaf ${aaf.version} + + + log4j + log4j + + + + + org.onap.optf.cmso + cmso-logger + 2.2.0-SNAPSHOT diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java b/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java index 8d053bf..23226ab 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +33,7 @@ package org.onap.observations; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Level; +import org.onap.logger.Logger; public class Observation { @@ -42,6 +43,8 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + private static Logger logger = new Logger(log, metrics, audit, errors, debug); + /** * Report. * @@ -53,35 +56,7 @@ public class Observation { public static void report(ObservationInterface obs, Exception exc, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, exc, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, exc, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, exc, arguments); - break; - case Level.INFO_INT: - log.info(obs, exc, arguments); - debug.debug(obs, exc, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, exc, arguments); - break; - case Level.TRACE_INT: - debug.trace(obs, exc, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, exc, arguments); - break; - default: - log.info(obs, exc, arguments); - } + logger.report(obs, exc, arguments); Mdc.clearCaller(); } @@ -94,35 +69,7 @@ public class Observation { public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.INFO_INT: - log.info(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.TRACE_INT: - debug.debug(obs, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, arguments); - break; - default: - log.info(obs, arguments); - } + logger.report(obs, arguments); Mdc.clearCaller(); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java deleted file mode 100644 index ebe657a..0000000 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2019 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. -*/ - -package org.onap.observations; - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; - -public interface ObservationInterface extends EELFResolvableErrorEnum { - public Enum getValue(); - - public Level getLevel(); - - public String getMessage(); - - public Status getStatus(); - - public String getDomain(); - - public String name(); - - public Boolean getAudit(); - - public Boolean getMetric(); -} diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java index 8544047..3069dbe 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java @@ -32,8 +32,9 @@ package org.onap.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; +import org.apache.logging.log4j.Level; + import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; public class ObservationObject implements ObservationInterface { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java index 584c140..1f394a3 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java @@ -38,7 +38,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.onap.observations.ObservationInterface; public enum LogMessages implements ObservationInterface { diff --git a/cmso-topology/pom.xml b/cmso-topology/pom.xml index 756d75b..deb6ecf 100644 --- a/cmso-topology/pom.xml +++ b/cmso-topology/pom.xml @@ -147,30 +147,6 @@ org.springframework spring-context-support - - com.att.eelf - eelf-core - ${eelf.version} - - - org.mockito - mockito-core - - - org.powermock - powermock-module - - - org.powermock - powermock-api-mockito - - - org.powermock - powermock-module-junit4 - - - - org.yaml snakeyaml @@ -178,11 +154,6 @@ - - javax.ws.rs - javax.ws.rs-api - 2.1 - @@ -237,6 +208,17 @@ org.onap.aaf.authz aaf-cadi-aaf ${aaf.version} + + + log4j + log4j + + + + + org.onap.optf.cmso + cmso-logger + 2.2.0-SNAPSHOT diff --git a/cmso-topology/src/main/java/org/onap/observations/Observation.java b/cmso-topology/src/main/java/org/onap/observations/Observation.java index e1ec30c..fdb8b51 100644 --- a/cmso-topology/src/main/java/org/onap/observations/Observation.java +++ b/cmso-topology/src/main/java/org/onap/observations/Observation.java @@ -1,5 +1,6 @@ /* * Copyright © 2019 AT&T Intellectual Property. + * Modified 2020 Nokia. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -28,7 +29,7 @@ package org.onap.observations; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.apache.log4j.Level; +import org.onap.logger.Logger; import org.onap.optf.cmso.topology.Application; @@ -42,46 +43,20 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + private static Logger logger = new Logger(log, metrics, audit, errors, debug); + /** * Report. * * @param obs the o - * @param execpt the e + * @param except the e * @param arguments the arguments */ // ************************************************************************************************* - public static void report(ObservationInterface obs, Exception execpt, String... arguments) { + public static void report(ObservationInterface obs, Exception except, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, execpt, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, execpt, arguments); - } - Level lev = obs.getLevel(); - switch (lev.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.INFO_INT: - log.info(obs, execpt, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, execpt, arguments); - break; - case Level.TRACE_INT: - debug.trace(obs, execpt, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, execpt, arguments); - break; - default: - log.info(obs, execpt, arguments); - } + logger.report(obs, except, arguments); Mdc.clearCaller(); } @@ -94,35 +69,7 @@ public class Observation { public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); Mdc.setObservation(obs); - if (obs.getAudit()) { - audit.info(obs, arguments); - } - if (obs.getMetric()) { - metrics.info(obs, arguments); - } - Level levl = obs.getLevel(); - switch (levl.toInt()) { - case Level.WARN_INT: - errors.warn(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.INFO_INT: - log.info(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.ERROR_INT: - errors.error(obs, arguments); - debug.debug(obs, arguments); - break; - case Level.TRACE_INT: - debug.debug(obs, arguments); - break; - case Level.DEBUG_INT: - debug.debug(obs, arguments); - break; - default: - log.info(obs, arguments); - } + logger.report(obs, arguments); Mdc.clearCaller(); } diff --git a/cmso-topology/src/main/java/org/onap/observations/ObservationInterface.java b/cmso-topology/src/main/java/org/onap/observations/ObservationInterface.java deleted file mode 100644 index 0dce93d..0000000 --- a/cmso-topology/src/main/java/org/onap/observations/ObservationInterface.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2019 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - * - * - * Unless otherwise specified, all documentation contained herein is licensed under the Creative - * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except - * in compliance with the License. You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.observations; - -import com.att.eelf.i18n.EELFResolvableErrorEnum; -import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; - -public interface ObservationInterface extends EELFResolvableErrorEnum { - public Enum getValue(); - - public Level getLevel(); - - public String getMessage(); - - public Status getStatus(); - - public String getDomain(); - - public String name(); - - public Boolean getAudit(); - - public Boolean getMetric(); -} diff --git a/cmso-topology/src/main/java/org/onap/observations/ObservationObject.java b/cmso-topology/src/main/java/org/onap/observations/ObservationObject.java index f1c1277..fa93cb3 100644 --- a/cmso-topology/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-topology/src/main/java/org/onap/observations/ObservationObject.java @@ -28,8 +28,8 @@ package org.onap.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; import com.att.eelf.i18n.EELFResourceManager; +import org.apache.logging.log4j.Level; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; /** diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java index b5f1c0e..4386435 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/common/LogMessages.java @@ -34,7 +34,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import javax.ws.rs.core.Response.Status; -import org.apache.log4j.Level; +import org.apache.logging.log4j.Level; import org.onap.observations.ObservationInterface; public enum LogMessages implements ObservationInterface { diff --git a/pom.xml b/pom.xml index 0a723ef..1d0238c 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,8 @@ 1.0.0 2.0.0 2.1.4 + 2.13.1 + 2.1 localhost:5000 nexus3.onap.org:10001 @@ -96,7 +98,8 @@ cmso-ticketmgt cmso-robot cmso-sonar - + cmso-logger +