package org.onap.demo.logging;
import javax.servlet.http.HttpServletRequest;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.onap.logging.ref.slf4j.ONAPLogAdapter;
import org.slf4j.LoggerFactory;
@Aspect
public class LoggingAspect {
@Before("execution(* org.onap.demo.logging.*.*(..))")
public void logBefore(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
Object servletRequest = args[0];
ONAPLogAdapter.HttpServletRequestAdapter requestAdapter = new
ONAPLogAdapter.HttpServletRequestAdapter(
new ONAPLogAdapter.HttpServletRequestAdapter((HttpServletRequest)servletRequest);
final ONAPLogAdapter adapter = new ONAPLogAdapter(
LoggerFactory.getLogger(joinPoint.getTarget().getClass()));
try {
adapter.entering(requestAdapter);
} finally {
}
}
adapter.exiting();@After("execution(* org.onap.demo.logging.*.*(..))")
public void logAfter(JoinPoint joinPoint) }
}
}
results - still working on passing in the servlet request
INFO: Server startup in 10663 ms
2018-07-09T01:37:45.402Z{
final ONAPLogAdapter adapter = new ONAPLogAdapter(
LoggerFactory.getLogger(joinPoint.getTarget().getClass()));
adapter.exiting();
}
results - still working on passing in the servlet request
INFO: Reloading Context with name [/logging-demo] is completed
2018-07-09T14:48:01.014Z http-nio-8080-exec-8 INFO org.onap.demo.logging.ApplicationService
InstanceUUID=67bc4b12-56a1-4b62-ab78-0c8ca8834383, RequestID=023af35a-b281-49c4-bf13-5167b1453780, ServiceName=/logging-demo/rest/health/health, InvocationID=94dc9e24-3722-43e5-8995-12f95e153ca3,
InvokeTimestamp=2018-07-09T14:48:01.008Z, PartnerName=, ClientIPAddress=0:0:0:0:0:0:0:1, ServerFQDN=localhost ENTRY
2018-07-09T14:48:01.014Z http-nio-8080-exec-28 INFO org.onap.demo.logging.ApplicationService
InstanceUUID=da6befe867bc4b12-319956a1-4cf14b62-80e8ab78-22dd8c2356ce0c8ca8834383, RequestID=a6e590e0023af35a-7330b281-475149c4-bdbcbf13-f367e5757d875167b1453780, ServiceName=/logging-demo/rest/health/health, InvocationID=8f674cf394dc9e24-823c3722-40a943e5-92d38995-dad45490e14112f95e153ca3,
InvokeTimestamp=2018-07-09T0109T14:3748:4501.397Z008Z, PartnerName=, ClientIPAddress=0:0:0:0:0:0:0:1, ServerFQDN=localhost Running /health ENTRY
2018-07-09T0109T14:3748:4501.403Z015Z http-nio-8080-exec-28 INFO org.onap.demo.logging.ApplicationService
ResponseCode=, InstanceUUID=da6befe867bc4b12-319956a1-4cf14b62-80e8ab78-22dd8c2356ce0c8ca8834383, RequestID=a6e590e0023af35a-7330b281-475149c4-bdbcbf13-f367e5757d875167b1453780, ServiceName=/logging-demo/rest/health/health, ResponseDescription=, InvocationID=8f674cf394dc9e24-823c3722-40a943e5-92d38995-dad45490e14112f95e153ca3, Severity=,
InvokeTimestamp=2018-07-09T0109T14:3748:4501.397Z008Z, PartnerName=, ClientIPAddress=0:0:0:0:0:0:0:1, ServerFQDN=localhost, StatusCode= EXIT
|