diff options
author | 2019-11-03 17:22:48 +0200 | |
---|---|---|
committer | 2019-11-05 15:52:05 +0200 | |
commit | 1e61754c29fc99636de692a0fb9d2ef1a4ba9e61 (patch) | |
tree | 90c20331d442c82dc955b0426d60b64a6ca353be /openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org | |
parent | 4a6e592af14fd3941df6e56e5b75c9ac5d5eb01b (diff) |
Align logging to Onap-ELS 2019.11
Change-Id: I1750493d5c9f2eab8c1395f0fbc9ae66cf74b0a6
Issue-ID: SDC-2639
Signed-off-by: Ben David, Elad (eb7504) <eb7504@intl.att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org')
7 files changed, 49 insertions, 25 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java index b6f8cfa8ff..aa4657f83e 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java @@ -95,7 +95,7 @@ public class EventTypeDiscriminator extends AbstractDiscriminator<ILoggingEvent> final Marker marker = event.getMarker(); if (marker != null) { - if (marker.contains(Markers.AUDIT)) { + if (marker.contains(Markers.ENTRY) || marker.contains(Markers.EXIT)){ return AUDIT; } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java index 3e44a34722..c4e780fa8f 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java @@ -16,6 +16,8 @@ package org.openecomp.sdc.logging.slf4j; +import org.onap.logging.ref.slf4j.ONAPLogConstants; + /** * MDC fields that represent audit data. * @@ -24,13 +26,13 @@ package org.openecomp.sdc.logging.slf4j; */ enum AuditField implements MDCField { - BEGIN_TIMESTAMP("BeginTimestamp"), + BEGIN_TIMESTAMP(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), END_TIMESTAMP("EndTimestamp"), ELAPSED_TIME("ElapsedTime"), - STATUS_CODE("StatusCode"), - RESPONSE_CODE("ResponseCode"), - RESPONSE_DESCRIPTION("ResponseDescription"), - CLIENT_IP_ADDRESS("ClientIpAddress"); + STATUS_CODE(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE), + RESPONSE_CODE(ONAPLogConstants.MDCs.RESPONSE_CODE), + RESPONSE_DESCRIPTION(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION), + CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS); private final String key; diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java index cce5f44863..87aa0e3a32 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java @@ -16,6 +16,8 @@ package org.openecomp.sdc.logging.slf4j; +import org.onap.logging.ref.slf4j.ONAPLogConstants; + /** * MDC fields that represent context data. * @@ -24,11 +26,11 @@ package org.openecomp.sdc.logging.slf4j; */ enum ContextField implements MDCField { - REQUEST_ID("RequestId"), - SERVICE_NAME("ServiceName"), - PARTNER_NAME("PartnerName"), - INSTANCE_ID("InstanceId"), - SERVER("Server"), + REQUEST_ID(ONAPLogConstants.MDCs.REQUEST_ID), + SERVICE_NAME(ONAPLogConstants.MDCs.SERVICE_NAME), + PARTNER_NAME(ONAPLogConstants.MDCs.PARTNER_NAME), + INSTANCE_ID(ONAPLogConstants.MDCs.INSTANCE_UUID), + SERVER(ONAPLogConstants.MDCs.SERVER_FQDN), SERVER_IP_ADDRESS("ServerIpAddress"); private final String key; diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java index 17439da161..3d9bbcfa53 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java @@ -16,6 +16,7 @@ package org.openecomp.sdc.logging.slf4j; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Marker; import org.slf4j.MarkerFactory; @@ -41,7 +42,9 @@ import org.slf4j.MarkerFactory; */ public class Markers { - public static final Marker AUDIT = MarkerFactory.getMarker("AUDIT"); + public static final Marker ENTRY = MarkerFactory.getMarker(ONAPLogConstants.Markers.ENTRY.getName()); + public static final Marker EXIT = MarkerFactory.getMarker(ONAPLogConstants.Markers.EXIT.getName()); + public static final Marker METRICS = MarkerFactory.getMarker("METRICS"); private Markers() { diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java index fda0c8b683..c4e8e143af 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java @@ -16,6 +16,8 @@ package org.openecomp.sdc.logging.slf4j; +import org.onap.logging.ref.slf4j.ONAPLogConstants; + /** * DC fields that represent metrics data. * @@ -24,15 +26,15 @@ package org.openecomp.sdc.logging.slf4j; */ public enum MetricsField implements MDCField { - BEGIN_TIMESTAMP("BeginTimestamp"), + BEGIN_TIMESTAMP(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP), END_TIMESTAMP("EndTimestamp"), ELAPSED_TIME("ElapsedTime"), - STATUS_CODE("StatusCode"), - RESPONSE_CODE("ResponseCode"), - RESPONSE_DESCRIPTION("ResponseDescription"), - CLIENT_IP_ADDRESS("ClientIpAddress"), + STATUS_CODE(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE), + RESPONSE_CODE(ONAPLogConstants.MDCs.RESPONSE_CODE), + RESPONSE_DESCRIPTION(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION), + CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS), TARGET_VIRTUAL_ENTITY("TargetVirtualEntity"), - TARGET_ENTITY("TargetEntity"); + TARGET_ENTITY(ONAPLogConstants.MDCs.TARGET_ENTITY); private final String key; diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java index 40684cc132..70e3dd6479 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java @@ -40,9 +40,9 @@ class RequestContextProvider implements ContextProvider { static ContextData to(Map<ContextField, String> values) { return ContextData.builder() - .requestId(values.get(ContextField.REQUEST_ID)) - .serviceName(values.get(ContextField.SERVICE_NAME)) - .partnerName(values.get(ContextField.PARTNER_NAME)).build(); + .requestId(values.get(ContextField.REQUEST_ID)) + .serviceName(values.get(ContextField.SERVICE_NAME)) + .partnerName(values.get(ContextField.PARTNER_NAME)).build(); } @Override @@ -58,7 +58,6 @@ class RequestContextProvider implements ContextProvider { } private void putIfNotNull(Map<ContextField, String> values, ContextField field, String value) { - if (value != null) { values.put(field, value); } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java index fbb5fbf1f2..f85a6bbe95 100644 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java +++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java @@ -114,11 +114,11 @@ class SLF4JLoggerWrapper implements Logger { @Override public boolean isAuditEnabled() { - return logger.isInfoEnabled(Markers.AUDIT); + return logger.isInfoEnabled(Markers.EXIT); } @Override - public void audit(AuditData data) { + public void auditEntry(AuditData data) { if (data == null) { return; // not failing if null @@ -126,7 +126,23 @@ class SLF4JLoggerWrapper implements Logger { try { putAuditOnMdc(data); - logger.info(Markers.AUDIT, ""); + logger.info(Markers.ENTRY, ""); + } finally { + clearAuditFromMdc(); + } + } + + + @Override + public void auditExit(AuditData data) { + + if (data == null) { + return; // not failing if null + } + + try { + putAuditOnMdc(data); + logger.info(Markers.EXIT, ""); } finally { clearAuditFromMdc(); } |