summaryrefslogtreecommitdiffstats
path: root/reference/logging-slf4j-demo/src/main
diff options
context:
space:
mode:
authorLuke Parker <lparker@amdocs.com>2018-05-22 17:35:18 +1000
committerLuke Parker <lparker@amdocs.com>2018-05-24 16:48:24 +1000
commit7a724b15b5a1266b8517d56008becd336db6a1c5 (patch)
tree8db4e6c052cda9fd166dff4270d8271c0bc2d042 /reference/logging-slf4j-demo/src/main
parentbdbcf1dbddd8c4646acd4187bc836102f493a542 (diff)
Rename slf4j ref impl, add constants
Change-Id: Ib3f24c3aa4974ac8c87fa969613192e884674f00 Issue-ID: LOG-115 Signed-off-by: Luke Parker <lparker@amdocs.com>
Diffstat (limited to 'reference/logging-slf4j-demo/src/main')
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/SLF4JRefApplication.java54
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/AbstractBean.java96
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Request.java64
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Response.java63
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/AbstractComponent.java278
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/ComponentAlpha.java53
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/ComponentBeta.java53
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/ComponentDelta.java53
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/ComponentGamma.java53
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/package-info.java26
-rw-r--r--reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/package-info.java30
-rw-r--r--reference/logging-slf4j-demo/src/main/resources/logback.xml35
-rw-r--r--reference/logging-slf4j-demo/src/main/webapp/WEB-INF/web.xml2
18 files changed, 990 insertions, 0 deletions
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/SLF4JRefApplication.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/SLF4JRefApplication.java
new file mode 100644
index 0000000..146f66b
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/SLF4JRefApplication.java
@@ -0,0 +1,54 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Spring launcher, for testing invocations via REST.
+ */
+@SpringBootApplication
+public class SLF4JRefApplication {
+
+ /** System property override, read by embedded Logback configuration. */
+ public static final String SLF4J_OUTPUT_DIRECTORY = "SLF4J_OUTPUT_DIRECTORY";
+
+ /**
+ * Launch from CLI.
+ * @param args command-line args.
+ * @throws Exception launch error.
+ */
+ public static void main(final String[] args) throws Exception {
+ initOutputDirectory();
+ SpringApplication.run(SLF4JRefApplication.class, args);
+ }
+
+ /**
+ * Make sure the output directory has a default value. (It'll be
+ * overridden by tests, but not in services.)
+ */
+ static void initOutputDirectory() {
+ System.getProperties().setProperty(SLF4J_OUTPUT_DIRECTORY,
+ System.getProperty(SLF4J_OUTPUT_DIRECTORY, "."));
+ }
+} \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/AbstractBean.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/AbstractBean.java
new file mode 100644
index 0000000..6c6060d
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/AbstractBean.java
@@ -0,0 +1,96 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.bean;
+
+import org.json.JSONObject;
+
+/**
+ * Base class for {@link Request} and {@link Response} beans, since
+ * they're almost the same thing.
+ */
+public abstract class AbstractBean {
+
+ /** Bean property. */
+ private String mService;
+
+ /** Bean property. */
+ private String mCode;
+
+ /** Bean property. */
+ private String mSeverity;
+
+ /**
+ * Getter.
+ * @return bean property.
+ */
+ public String getService() {
+ return this.mService;
+ }
+
+ /**
+ * Setter.
+ * @param service bean property.
+ */
+ public void setService(final String service) {
+ this.mService = service;
+ }
+
+ /**
+ * Getter.
+ * @return bean property.
+ */
+ public String getCode() {
+ return this.mCode;
+ }
+
+ /**
+ * Setter.
+ * @param code bean property.
+ */
+ public void setCode(final String code) {
+ this.mCode = code;
+ }
+
+ /**
+ * Getter.
+ * @return bean property.
+ */
+ public String getSeverity() {
+ return this.mSeverity;
+ }
+
+ /**
+ * Setter.
+ * @param severity bean property.
+ */
+ public void setSeverity(final String severity) {
+ this.mSeverity = severity;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return new JSONObject(this).toString(4);
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Request.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Request.java
new file mode 100644
index 0000000..5318333
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Request.java
@@ -0,0 +1,64 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Test class, describing a request to be executed.
+ */
+public class Request extends AbstractBean {
+
+ /** Subrequests to be executed. */
+ private final List<Request> mRequests = new ArrayList<>();
+
+ /**
+ * Get subrequests.
+ * @return subrequests.
+ */
+ public List<Request> getRequests() {
+ return mRequests;
+ }
+
+ /**
+ * Parse from serialized form.
+ * @param in JSON.
+ * @return parsed.
+ */
+ public static Request fromJSON(final JSONObject in) {
+ final Request request = new Request();
+ request.setService(in.optString("service"));
+ request.setCode(in.optString("code"));
+ request.setSeverity(in.optString("severity"));
+ final JSONArray requests = in.optJSONArray("requests");
+ if (requests != null) {
+ for (int i = 0 ; i < requests.length() ; i++) {
+ request.getRequests().add(Request.fromJSON(requests.getJSONObject(i)));
+ }
+ }
+ return request;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Response.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Response.java
new file mode 100644
index 0000000..b0c6a4a
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/Response.java
@@ -0,0 +1,63 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Test class, describing an outcome that should be reported.
+ */
+public class Response extends AbstractBean {
+
+ /** Delegate responses. */
+ private final List<Response> mResponses = new ArrayList<>();
+
+ /**
+ * Get delegate responses.
+ * @return responses.
+ */
+ public List<Response> getResponses() {
+ return mResponses;
+ }
+
+ /**
+ * Parse from serialized form.
+ * @param in JSON.
+ * @return parsed.
+ */
+ public static Response fromJSON(final JSONObject in) {
+ final Response request = new Response();
+ request.setCode(in.optString("code"));
+ request.setSeverity(in.optString("severity"));
+ final JSONArray responses = in.optJSONArray("responses");
+ if (responses != null) {
+ for (int i = 0 ; i < responses.length() ; i++) {
+ request.getResponses().add(Response.fromJSON(responses.getJSONObject(i)));
+ }
+ }
+ return request;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/package-info.java
new file mode 100644
index 0000000..2364f9f
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/bean/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.bean;
+
+/**
+ * Simple request/responses beans for testcases.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/AbstractComponent.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/AbstractComponent.java
new file mode 100644
index 0000000..b6a2c95
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/AbstractComponent.java
@@ -0,0 +1,278 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.mashape.unirest.http.HttpResponse;
+import com.mashape.unirest.http.JsonNode;
+import com.mashape.unirest.http.Unirest;
+import com.mashape.unirest.http.exceptions.UnirestException;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+import org.onap.logging.ref.slf4j.ONAPLogAdapter;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.logging.ref.slf4j.demo.bean.Request;
+import org.onap.logging.ref.slf4j.demo.bean.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Base class for <tt>Alpha</tt>, <tt>Beta</tt> and <tt>Gamma</tt>
+ * and <tt>Delta</tt> controllers, implementing all the actual logic.
+ *
+ * <p>(The subclasses provide nothing but identifiers to allow them
+ * to be distinguished from one another, for the purposes of addressing
+ * requests and generating the call graph from their logger output.)</p>
+ */
+@RestController
+public abstract class AbstractComponent {
+
+ /**
+ * Test switch, routing invocations between components in-process,
+ * rather than via REST over HTTP.
+ */
+ private static boolean sInProcess;
+
+ /**
+ * Get service identifier, used to derive {@link #getServiceName()},
+ * <tt>PartnerName</tt>, etc.
+ * @return <tt>alpha</tt>, <tt>beta</tt>, <tt>gamma</tt>.
+ */
+ protected abstract String getId();
+
+ /**
+ * Get component UUID.
+ * @return globally unique ID string.
+ */
+ protected abstract String getInstanceUUID();
+
+ /**
+ * Execute REST request.
+ * @param request request data.
+ * @param http HTTP request.
+ * @return response data.
+ * @throws UnirestException REST error.
+ */
+ @RequestMapping(value = "/invoke",
+ method = RequestMethod.POST,
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ public Response execute(final Request request,
+ final HttpServletRequest http) throws UnirestException {
+
+ final ONAPLogAdapter adapter = new ONAPLogAdapter(this.getLogger());
+
+ try {
+
+ adapter.entering(new ONAPLogAdapter.HttpServletRequestAdapter(http));
+
+ final Response response = new Response();
+ response.setService(request.getService());
+ final String code = StringUtils.defaultString(request.getCode(), "OK").toUpperCase();
+ response.setCode(this.getId() + "." + code);
+ response.setSeverity(StringUtils.defaultString(request.getSeverity(), "INFO"));
+
+ for (final Request target : request.getRequests()) {
+ final Response targetResponse = this.executeDelegate(target, http, adapter);
+ response.getResponses().add(targetResponse);
+ }
+
+ return response;
+ }
+ finally {
+ adapter.exiting();
+ }
+ }
+
+ /**
+ * Set in-process mode, for unit testing.
+ */
+ static void setInProcess() {
+ sInProcess = true;
+ }
+
+ /**
+ * Execute request.
+ * @param request to be executed.
+ * @param http incoming HTTP request.
+ * @param logger logging adapter.
+ * @return response
+ */
+ private Response executeDelegate(final Request request,
+ final HttpServletRequest http,
+ final ONAPLogAdapter logger) {
+
+
+ notNull(request);
+ notNull(http);
+
+ // Downstream call.
+
+ try {
+
+ if (sInProcess) {
+ return this.executeInProcess(request, logger);
+ }
+
+ return this.executeREST(request, http, logger);
+ }
+ catch (final UnirestException | ReflectiveOperationException e) {
+ logger.unwrap().error("Execute error", e);
+ final Response response = new Response();
+ response.setCode((this.getServiceName() + ".INVOKE_ERROR").toUpperCase(Locale.getDefault()));
+ response.setSeverity("ERROR");
+ return response;
+ }
+ }
+
+ /**
+ * Execute invocation over REST.
+ * @param request mock request to be executed.
+ * @param http HTTP request, used (only) to address the outgoing request.
+ * @param logger logger adapter.
+ * @return invocation response.
+ * @throws UnirestException REST error.
+ */
+ private Response executeREST(final Request request,
+ final HttpServletRequest http,
+ final ONAPLogAdapter logger) throws UnirestException {
+ // Otherwise via REST.
+
+ logger.unwrap().info("Sending:\n{}", request);
+ final StringBuilder url = new StringBuilder();
+ url.append(http.getProtocol()).append("://");
+ url.append(http.getServerName()).append(':');
+ url.append(http.getServerPort()).append("/services/").append(request.getService());
+
+ final UUID invocationID = logger.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS);
+ final HttpResponse<JsonNode> response =
+ Unirest.post(url.toString())
+ .header(ONAPLogConstants.Headers.REQUEST_ID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID))
+ .header(ONAPLogConstants.Headers.INVOCATION_ID, invocationID.toString())
+ .header(ONAPLogConstants.Headers.PARTNER_NAME, this.getServiceName())
+ .header("Accept", MediaType.APPLICATION_JSON_VALUE)
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .body(request)
+ .asJson();
+
+ // Parse response.
+
+ final JSONObject responseJSON = response.getBody().getObject();
+ logger.unwrap().info("Received:\n{}", responseJSON);
+ return Response.fromJSON(responseJSON);
+ }
+
+ /**
+ * Execute request in-process.
+ * @param request mock request to be executed.
+ * @param logger logger adapter.
+ * @return invocation response.
+ * @throws ReflectiveOperationException error loading target class.
+ * @throws UnirestException REST error.
+ */
+ private Response executeInProcess(final Request request,
+ final ONAPLogAdapter logger) throws ReflectiveOperationException, UnirestException {
+
+ logger.unwrap().info("Executing in-process:\n{}", request);
+
+ // Derive the name of the delegate class.
+
+ final String delegateClass
+ = AbstractComponent.class.getPackage().getName() + "." + request.getService()
+ + ".Component" + request.getService().substring(0, 1).toUpperCase()
+ + request.getService().substring(1);
+ logger.unwrap().info("Invoking in-process [{}].", delegateClass);
+ final AbstractComponent component = (AbstractComponent)Class.forName(delegateClass).newInstance();
+
+ // Using Spring mock since we're not *actually* going over HTTP.
+
+ final MockHttpServletRequest mock = new MockHttpServletRequest();
+
+ // Generate INVOCATION_ID, and set MDCs aside for safekeeping.
+ // (This is because when mocking, everything happens in the same thread.)
+
+ final UUID invocationID = logger.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS);
+ final String requestID = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ final Map<String, String> safekeeping = MDC.getCopyOfContextMap();
+
+ // Set headers.
+
+ mock.addHeader(ONAPLogConstants.Headers.REQUEST_ID, StringUtils.defaultString(requestID));
+ mock.addHeader(ONAPLogConstants.Headers.INVOCATION_ID, invocationID.toString());
+ mock.addHeader(ONAPLogConstants.Headers.PARTNER_NAME, this.getServiceName());
+
+ try {
+
+ MDC.clear();
+
+ // Execute.
+
+ return component.execute(request, mock);
+ }
+ finally {
+
+ // Restore MDCs.
+
+ safekeeping.forEach((k, v) -> MDC.put(k, v));
+ }
+ }
+
+ /**
+ * Ensure non-nullness.
+ * @param in to be checked.
+ * @param <T> type.
+ * @return input value, not null.
+ */
+ private static <T> T notNull(final T in) {
+ if (in == null) {
+ throw new AssertionError("");
+ }
+ return in;
+ }
+
+ /**
+ * Get service name, with default.
+ * @return service name, suitable for logging as MDC.
+ */
+ private String getServiceName() {
+ return "service." + StringUtils.defaultString(this.getId(), "unnamed");
+ }
+
+ /**
+ * Get logger instance.
+ * @return logger.
+ */
+ private Logger getLogger() {
+ return LoggerFactory.getLogger(this.getClass());
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/ComponentAlpha.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/ComponentAlpha.java
new file mode 100644
index 0000000..d5cf182
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/ComponentAlpha.java
@@ -0,0 +1,53 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.alpha;
+
+import java.util.UUID;
+
+import org.onap.logging.ref.slf4j.demo.component.AbstractComponent;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Discrete service, identical to the others but with its own identifiers.
+ */
+@RequestMapping("/services/alpha")
+public class ComponentAlpha extends AbstractComponent {
+
+ /** Component instance UUID constant. */
+ private static final String INSTANCE_UUID = UUID.randomUUID().toString();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getId() {
+ return "alpha";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInstanceUUID() {
+ return INSTANCE_UUID;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/package-info.java
new file mode 100644
index 0000000..4fa0fbc
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/alpha/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.alpha;
+
+/**
+ * Example service.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/ComponentBeta.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/ComponentBeta.java
new file mode 100644
index 0000000..9a4e6eb
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/ComponentBeta.java
@@ -0,0 +1,53 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.beta;
+
+import java.util.UUID;
+
+import org.onap.logging.ref.slf4j.demo.component.AbstractComponent;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Discrete service, identical to the others but with its own identifiers.
+ */
+@RequestMapping("/services/beta")
+public class ComponentBeta extends AbstractComponent {
+
+ /** Component instance UUID constant. */
+ private static final String INSTANCE_UUID = UUID.randomUUID().toString();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getId() {
+ return "beta";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInstanceUUID() {
+ return INSTANCE_UUID;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/package-info.java
new file mode 100644
index 0000000..68d7f74
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/beta/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.beta;
+
+/**
+ * Example service.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/ComponentDelta.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/ComponentDelta.java
new file mode 100644
index 0000000..d63d80a
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/ComponentDelta.java
@@ -0,0 +1,53 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.delta;
+
+import java.util.UUID;
+
+import org.onap.logging.ref.slf4j.demo.component.AbstractComponent;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Discrete service, identical to the others but with its own identifiers.
+ */
+@RequestMapping("/services/delta")
+public class ComponentDelta extends AbstractComponent {
+
+ /** Component instance UUID constant. */
+ private static final String INSTANCE_UUID = UUID.randomUUID().toString();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getId() {
+ return "delta";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInstanceUUID() {
+ return INSTANCE_UUID;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/package-info.java
new file mode 100644
index 0000000..4b02ab4
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/delta/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.delta;
+
+/**
+ * Example service.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/ComponentGamma.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/ComponentGamma.java
new file mode 100644
index 0000000..9294743
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/ComponentGamma.java
@@ -0,0 +1,53 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.gamma;
+
+import java.util.UUID;
+
+import org.onap.logging.ref.slf4j.demo.component.AbstractComponent;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Discrete service, identical to the others but with its own identifiers.
+ */
+@RequestMapping("/services/gamma")
+public class ComponentGamma extends AbstractComponent {
+
+ /** Component instance UUID constant. */
+ private static final String INSTANCE_UUID = UUID.randomUUID().toString();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getId() {
+ return "gamma";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInstanceUUID() {
+ return INSTANCE_UUID;
+ }
+}
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/package-info.java
new file mode 100644
index 0000000..7f5e30a
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/gamma/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component.gamma;
+
+/**
+ * Example service.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/package-info.java
new file mode 100644
index 0000000..c650948
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/component/package-info.java
@@ -0,0 +1,26 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo.component;
+
+/**
+ * Components that demonstrate usage and participate in the test.
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/package-info.java b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/package-info.java
new file mode 100644
index 0000000..feb5e85
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/java/org/onap/logging/ref/slf4j/demo/package-info.java
@@ -0,0 +1,30 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.logging
+ * ================================================================================
+ * Copyright © 2018 Amdocs
+ * 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.logging.ref.slf4j.demo;
+
+/**
+ * Minimal, spring-boot refernce example.
+ *
+ * <p>Code that exists for testing can have whatever dependencies
+ * it likes, but take care with the contents of <tt>common</tt>,
+ * since it may be useful elsewhere.</p>
+ */ \ No newline at end of file
diff --git a/reference/logging-slf4j-demo/src/main/resources/logback.xml b/reference/logging-slf4j-demo/src/main/resources/logback.xml
new file mode 100644
index 0000000..554d712
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/resources/logback.xml
@@ -0,0 +1,35 @@
+<configuration>
+
+ <property name="p_tim" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}"/>
+ <property name="p_lvl" value="%level"/>
+ <property name="p_log" value="%logger"/>
+ <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/>
+ <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/>
+ <property name="p_thr" value="%thread"/>
+ <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${SLF4J_OUTPUT_DIRECTORY}/output.log</file>
+ <encoder>
+ <pattern>${pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <logger level="debug" name="org.onap.logging.ref.slf4j" additivity="false">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+ <root level="error">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
diff --git a/reference/logging-slf4j-demo/src/main/webapp/WEB-INF/web.xml b/reference/logging-slf4j-demo/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..91a632c
--- /dev/null
+++ b/reference/logging-slf4j-demo/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="slf4j-reference" version="3.0"/>