Update cipher logging

This commit is contained in:
2024-04-28 15:26:40 -04:00
parent 1183cab5f1
commit cc0aa2986d
26 changed files with 94 additions and 45 deletions

View File

@@ -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");
}
}

View File

@@ -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>

View File

@@ -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