diff --git a/pom.xml b/pom.xml
index cd32bf8..b7821dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@
1.8
UTF-8
UTF-8
+ 0.1.5
@@ -98,6 +99,14 @@
true
+
+
+ net.logstash.logback
+ logstash-logback-encoder
+ 6.4
+
+
+
org.springframework.boot
diff --git a/src/main/java/cryptosky/me/consumers/PriceConsumer.java b/src/main/java/cryptosky/me/consumers/PriceConsumer.java
index c14ae9c..b1a9ded 100644
--- a/src/main/java/cryptosky/me/consumers/PriceConsumer.java
+++ b/src/main/java/cryptosky/me/consumers/PriceConsumer.java
@@ -23,6 +23,7 @@ import java.util.concurrent.CountDownLatch;
import static cryptosky.me.ArtemisSyncMessaging.*;
import static cryptosky.me.helpers.Utils.getCorrelationId;
+import static cryptosky.me.logging.CorrelationInfo.setCorrelationId;
import static java.lang.String.format;
@Component
@@ -60,6 +61,8 @@ public class PriceConsumer {
logger.info("Received Message: " + message.getBody(String.class));
try {
+ setCorrelationId(correlationId);
+
if (message.getBody(String.class) == null | message.getBody(String.class).equals("")) {
throw new NoBodyOrStringException();
}
diff --git a/src/main/java/cryptosky/me/logging/CorrelationInfo.java b/src/main/java/cryptosky/me/logging/CorrelationInfo.java
new file mode 100644
index 0000000..33473fb
--- /dev/null
+++ b/src/main/java/cryptosky/me/logging/CorrelationInfo.java
@@ -0,0 +1,22 @@
+package cryptosky.me.logging;
+
+import org.slf4j.MDC;
+
+public class CorrelationInfo {
+
+ public static final String CORRELATION_ID = "X-CRYPTO-Correlation-ID";
+ public static final String SYNC_ID = "X-CRYPTO-Sync-ID";
+
+ public static void setCorrelationId(String correlationId) {
+ MDC.put(CORRELATION_ID, correlationId);
+ }
+
+ public static void setSyncId(String syncId) {
+ MDC.put(SYNC_ID, syncId);
+ }
+
+ public static void clear() {
+ MDC.remove(CORRELATION_ID);
+ MDC.remove(SYNC_ID);
+ }
+}
diff --git a/src/main/java/cryptosky/me/pricing/service/PriceService.java b/src/main/java/cryptosky/me/pricing/service/PriceService.java
index 26bf4a8..25dd97c 100644
--- a/src/main/java/cryptosky/me/pricing/service/PriceService.java
+++ b/src/main/java/cryptosky/me/pricing/service/PriceService.java
@@ -32,6 +32,7 @@ import static cryptosky.me.ArtemisSyncMessaging.*;
import static cryptosky.me.SupportedCurrencies.*;
import static cryptosky.me.helpers.Utils.format;
+import static cryptosky.me.logging.CorrelationInfo.setSyncId;
@Service
public class PriceService {
@@ -79,6 +80,8 @@ public class PriceService {
@Transactional
public void createRecord(CryptoPriceModel cryptoPriceModel, String correlationId, String syncId, TextMessage message) {
try {
+ setSyncId(syncId);
+
switch (cryptoPriceModel.getType()) {
case BTC:
BtcPriceModel priceModel = new BtcPriceModel();
diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000..cdde4ef
--- /dev/null
+++ b/src/main/resources/logback-spring.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ [ignore]
+ [ignore]
+
+
+
+
+
+
+
+ %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg {%mdc}%n%throwable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+