From 88b135a65af713dee1b33dab29fd9e568c0594b0 Mon Sep 17 00:00:00 2001 From: vempo Date: Thu, 16 Aug 2018 19:21:46 +0300 Subject: Fixed logback test config for multiple modules Also removed unused logging code. Change-Id: Iee9a74638e889142f1bb4e01c75c8ed3377357a8 Issue-ID: SDC-1656 Signed-off-by: vempo --- .../openecomp-sdc-logging-core/README | 29 -- .../sdc/logging/logback/DispatchingAppender.java | 143 --------- .../src/test/resources/README | 8 - .../src/test/resources/dispatching-logback.xml | 335 --------------------- .../src/test/resources/logback-test.xml | 36 +-- .../src/test/resources/sifting-logback.xml | 42 --- 6 files changed, 4 insertions(+), 589 deletions(-) delete mode 100644 openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/README delete mode 100644 openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java delete mode 100644 openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/README delete mode 100644 openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/dispatching-logback.xml delete mode 100644 openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/sifting-logback.xml (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core') diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/README b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/README deleted file mode 100644 index 779c5d99df..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/README +++ /dev/null @@ -1,29 +0,0 @@ -The purpose of this module is to make a Web application meet the OPENECOMP logging requirements described in -OPENECOMP platform application logging guidelines. - -The default out-of-the box solution is based on SLF4J. - -It introduces three major areas of functionality as follows: - -1. Routing of logging messages for the Logback library, so that all logging events are written to separate files -according to their type. - -2. An AOP aspect for measuring execution time and logging it, so that the application code is not contaminated with -this type of logging. - -3. Collecting and populating the context of a Web API request and propagating it to every logging event. - -TODO: - -1. MetricsAspect - - Configurable metrics message - - Make sure there are no exceptions but applicative ones - -2. EventTypeDiscriminator - - Make event types configurable to make the names of log files easily customizable - -3. DispatchingAppender - - Read appenders from configuration, so that there is no need in EELF loggers - - Simpler use of discriminator or an entirely different mechanism - - Better appender name pattern, or mapping between a discriminating value and an appender name - - Discard the appenders cache on configuration changes diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java deleted file mode 100644 index fb0ceb97e2..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright © 2016-2017 European Support Limited - * - * 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. - */ - -package org.openecomp.sdc.logging.logback; - -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.classic.sift.MDCBasedDiscriminator; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.Appender; -import ch.qos.logback.core.AppenderBase; -import ch.qos.logback.core.joran.spi.DefaultClass; -import ch.qos.logback.core.sift.Discriminator; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.slf4j.LoggerFactory; - -/** - *

Allows to use EELF logging configuration almost as is, by using a custom routing function, but pre-configured - * appenders attached to the standard EELF loggers.

- * - *

Changes that must be made in logback.xml supplied with EELF:

- * - *
- *     <appender name="DISPATCHER" class="org.openecomp.sdc.logging.logback.DispatchingAppender">
- *          <discriminator class="org.openecomp.sdc.logging.logback.EventTypeDiscriminator"/>
- *          <appenderNamePattern>asyncEELF%s</appenderNamePattern>
- *     </appender>
- *
- *     <root level="INFO" additivity="false">
- *          <appender-ref ref="DISPATCHER" />
- *      </root>
- * 
- * - * @author EVITALIY - * @since 17/08/2016. - */ -public class DispatchingAppender extends AppenderBase { - - // "magic" appender to indicate a missing appender - private static final Appender NO_APPENDER = new DispatchingAppender(); - - private final Map> appenders = new ConcurrentHashMap<>(); - - private Discriminator discriminator; - private String appenderNamePattern; - - @DefaultClass(MDCBasedDiscriminator.class) - public void setDiscriminator(Discriminator discriminator) { - this.discriminator = discriminator; - } - - public Discriminator getDiscriminator() { - return this.discriminator; - } - - public void setAppenderNamePattern(String pattern) { - this.appenderNamePattern = pattern; - } - - public String getAppenderNamePattern() { - return this.appenderNamePattern; - } - - @Override - protected void append(ILoggingEvent event) { - - if (this.isStarted()) { - - String discriminatingValue = this.discriminator.getDiscriminatingValue(event); - String appenderName = String.format(this.appenderNamePattern, discriminatingValue); - Appender appender = this.lookupAppender(appenderName); - if (appender == NO_APPENDER) { - this.addError(String.format("Appender %s does not exist", appenderName)); - } else { - appender.doAppend(event); - } - } - } - - private Appender lookupAppender(String key) { - - Appender appender = appenders.get(key); - if (appender != null) { - return appender; - } - - LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); - for (Logger log : context.getLoggerList()) { - - Iterator> iterator = log.iteratorForAppenders(); - while (iterator.hasNext()) { - - Appender element = iterator.next(); - if (key.equals(element.getName())) { - this.appenders.putIfAbsent(key, element); - return element; - } - } - } - - // to avoid consecutive lookups if the required appender does not exist - this.appenders.putIfAbsent(key, NO_APPENDER); - return NO_APPENDER; - } - - @Override - public void start() { - - int errors = 0; - if (this.discriminator == null) { - this.addError("Missing discriminator. Aborting"); - } - - if (!this.discriminator.isStarted()) { - this.addError("Discriminator has not started successfully. Aborting"); - ++errors; - } - - if (this.appenderNamePattern == null) { - this.addError("Missing name pattern. Aborting"); - ++errors; - } - - if (errors == 0) { - super.start(); - } - } -} diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/README b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/README deleted file mode 100644 index 430f36d760..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/README +++ /dev/null @@ -1,8 +0,0 @@ -Different routing/dispatching mechanisms can be tested using -Dlogback.configurationFile and a custom configuration -file, for example - --Dlogback.configurationFile=/dispatching-logback.xml - -or - --Dlogback.configurationFile=/sifting-logback.xml \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/dispatching-logback.xml b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/dispatching-logback.xml deleted file mode 100644 index c6c51f14c1..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/dispatching-logback.xml +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${defaultPattern} - - - - - - - - - - - - ${logDirectory}/${generalLogName}.log - - ${logDirectory}/${generalLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - - 256 - - - - - - ${logDirectory}/${securityLogName}.log - - ${logDirectory}/${securityLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - - 256 - 0 - - - - - - ${logDirectory}/${performanceLogName}.log - - ${logDirectory}/${performanceLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - true - ${defaultPattern} - - - - 256 - - - - - - ${logDirectory}/${serverLogName}.log - - ${logDirectory}/${serverLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - 256 - - - - - - - ${logDirectory}/${policyLogName}.log - - ${logDirectory}/${policyLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - 256 - - - - - - - - ${logDirectory}/${auditLogName}.log - - ${logDirectory}/${auditLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - 256 - - - - - ${logDirectory}/${metricsLogName}.log - - ${logDirectory}/${metricsLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - - ${defaultPattern} - - - - - - 256 - - - - - ${logDirectory}/${errorLogName}.log - - ${logDirectory}/${errorLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - - 256 - - - - - ${debugLogDirectory}/${debugLogName}.log - - ${debugLogDirectory}/${debugLogName}.%i.log.zip - - 1 - 9 - - - 5MB - - - ${debugLoggerPattern} - - - - - 256 - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - asyncEELF%s - - - - - - - \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/logback-test.xml b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/logback-test.xml index 4029db2215..f9fa3d88e8 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/logback-test.xml +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/logback-test.xml @@ -1,41 +1,13 @@ - - - - - - - - + - ${defaultPattern} + %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - - - - - ${logDirectory}/${eventType}.log - - ${logDirectory}/${eventType}.%i.log.zip - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - - - - + + \ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/sifting-logback.xml b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/sifting-logback.xml deleted file mode 100644 index b713b54b75..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/resources/sifting-logback.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - ${defaultPattern} - - - - - - - - ${logDirectory}/${eventType}.log - - ${logDirectory}/${eventType}.%i.log.zip - 1 - 9 - - - 5MB - - - ${defaultPattern} - - - - - - - - - - \ No newline at end of file -- cgit 1.2.3-korg