Update cipher logging
This commit is contained in:
@@ -4,6 +4,7 @@ package com.mattrixwv.cipherstream.aspect;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -35,7 +36,17 @@ public class CipherStreamLoggingAspect{
|
||||
|
||||
@AfterReturning(pointcut = "cipherMethod() && postFunction()", returning = "returnedJson")
|
||||
public void getCipherInfo(ObjectNode returnedJson){
|
||||
//Extract JSON to MDC
|
||||
returnedJson.fields().forEachRemaining(entry -> {
|
||||
if(entry.getValue().isTextual()){
|
||||
MDC.put(entry.getKey(), entry.getValue().asText());
|
||||
}
|
||||
else{
|
||||
MDC.put(entry.getKey(), entry.getValue().toString());
|
||||
}
|
||||
});
|
||||
|
||||
//Print a log
|
||||
log.info("CipherStream log {}", returnedJson);
|
||||
log.info("CipherStream log");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
</Pattern>
|
||||
</PatternLayout>
|
||||
</Console>
|
||||
|
||||
|
||||
<RollingRandomAccessFile name="file" fileName="cipherStreamAPI.log" filePattern="%d{MM-dd-yyyy}-cipherStreamAPI.log.gz" immediateFlush="true">
|
||||
<JsonTemplateLayout eventTemplateUri="classpath:template.json"></JsonTemplateLayout>
|
||||
<Policies>
|
||||
@@ -17,6 +19,16 @@
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="20"/>
|
||||
</RollingRandomAccessFile>
|
||||
|
||||
|
||||
<Console name="consoleJSON" target="SYSTEM_OUT">
|
||||
<JsonTemplateLayout eventTemplateUri="classpath:template.json"/>
|
||||
</Console>
|
||||
|
||||
|
||||
<Socket name="graylog" host="loggingpi.mattrixwv.com" port="1502">
|
||||
<JsonTemplateLayout eventTemplateUri="classpath:template.json"/>
|
||||
</Socket>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"timestamp": {
|
||||
"$resolver": "timestamp",
|
||||
"pattern": {
|
||||
"format": "yyy-MM-dd HH:mm:ss.SSSZ"
|
||||
"format": "yyyy-MM-dd HH:mm:ss.SSSZ"
|
||||
}
|
||||
},
|
||||
"level": {
|
||||
@@ -13,6 +13,15 @@
|
||||
"$resolver": "mdc",
|
||||
"key": "requestId"
|
||||
},
|
||||
"logger": {
|
||||
"$resolver": "logger",
|
||||
"field": "name"
|
||||
},
|
||||
"mdc":{
|
||||
"$resolver": "mdc",
|
||||
"flatten": false,
|
||||
"stringified": false
|
||||
},
|
||||
"message": {
|
||||
"$resolver": "message",
|
||||
"stringified": true
|
||||
|
||||
Reference in New Issue
Block a user