feat: 서버 실행결과 로그 출력 여부 설정 추가

main
minuk926 2 years ago
parent bf7ac01143
commit 9a02204c27

@ -12,6 +12,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
@ -19,40 +20,21 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import lombok.extern.slf4j.Slf4j;
import kr.xit.framework.support.mybatis.PagingConstants; import kr.xit.framework.support.mybatis.PagingConstants;
import kr.xit.framework.support.mybatis.paging.domain.Paginator; import kr.xit.framework.support.mybatis.paging.domain.Paginator;
import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@Component @Component
@Aspect @Aspect
public class LogAopAdvice { public class LogAopAdvice {
@Value("#{prop['debug.result.log.trace']}")
private boolean isRsltLog;
/**
* <pre>
* AOP before Advice : JoinPoint (JointPoint Arround )
* after-returning Advice : JoinPoint, Object around Advice :
* ProceedingJoinPoint - MethodInterceptor &lt;aop:config&gt; &lt;aop:config&gt;
* &lt;aop:aspect id="aroundProceed" ref="huimaiAopdvice"&gt; &lt;aop:pointcut id="pointCut"
* expression="execution(* com.huimai.biz.*.controller.*.*(..))"/&gt;
* &lt;aop:around method="aroundProceed" pointcut-ref="pointCut"/&gt;
* &lt;/aop:aspect&gt; &lt;aop:aspect id="afterProceed" ref="huimaiAopdvice"&gt;
* &lt;aop:pointcut id="pointCut"
* expression="execution(* com.huimai.biz.*.controller.*.*(..))"/&gt;
* &lt;aop:after-returning method="afterProceed" pointcut-ref="pointCut"
* returning="ret"/&gt; &lt;/aop:aspect&gt; &lt;aop:aspect id="beforeProceed"
* ref="huimaiAopdvice"&gt; &lt;aop:pointcut id="pointCut"
* expression="execution(* com.huimai.biz.*.controller.*.*(..))"/&gt;
* &lt;aop:before method="beforeProceed" pointcut-ref="pointCut"/&gt;
* &lt;/aop:aspect&gt; &lt;/aop:config&gt;
* ("execution(public * com.sjf..controller.*.*(..))") : com.sjf controller class
* --&gt; ("execution(public * com.sjf..controller.*(..))")
*</pre>
*/
//@Around("execution((public * project..controller.*.*(..))||execution(public * framework..controller.*.*(..))) && !@annotation(com.tistory.eisen.annotation.SkipChecking)")
@Around("execution(public * kr.xit.framework..web.*.*(..))||execution(public * kr.xit.fims..web.*.*(..))") @Around("execution(public * kr.xit.framework..web.*.*(..))||execution(public * kr.xit.fims..web.*.*(..))")
public Object aroundProceed(ProceedingJoinPoint pjp) throws Throwable { public Object aroundProceed(ProceedingJoinPoint pjp) throws Throwable {
String methodName = pjp.getSignature().getName(); String methodName = pjp.getSignature().getName();
// StopWatch sw = new StopWatch(pjp.toShortString());// // StopWatch sw = new StopWatch(pjp.toShortString());//
// sw.start(methodName); // sw.start(methodName);
@ -63,21 +45,16 @@ public class LogAopAdvice {
HttpServletRequest request = servletRequestAttributes.getRequest(); HttpServletRequest request = servletRequestAttributes.getRequest();
requestLog(request); requestLog(request);
Object[] args = pjp.getArgs(); Object[] args = pjp.getArgs();
//if (args.length > 0){
// log.info("//==============================Parameters====================================");
// log.debug("Http Request Parameters = {}", args[0]);
// log.info("=========================================================================//");
//}
//TODO 필요시 insert log //TODO 필요시 insert log
//logInsert(methodName, request, paraMap+""); //logInsert(methodName, request, paraMap+"");
Object rtnObj = pjp.proceed(); Object rtnObj = pjp.proceed();
// Object rtnObj = pjp.proceed(args); if(isRsltLog) {
log.info("//==============================Result===================================="); log.info("//==============================Result====================================");
log.info("{}", rtnObj); log.info("{}", rtnObj);
log.info("=========================================================================//"); log.info("=========================================================================//");
}
Object pageObject = RequestContextHolder.getRequestAttributes().getAttribute(PagingConstants.Session.PAGE_INFO.getCode(), RequestAttributes.SCOPE_REQUEST); Object pageObject = RequestContextHolder.getRequestAttributes().getAttribute(PagingConstants.Session.PAGE_INFO.getCode(), RequestAttributes.SCOPE_REQUEST);
if(pageObject != null && rtnObj != null){ if(pageObject != null && rtnObj != null){
Paginator paginator = (Paginator)pageObject; Paginator paginator = (Paginator)pageObject;

@ -120,6 +120,7 @@ Globals.Xit.Bbs.useAt = Y
# ############################################## # # ############################################## #
# //XitFramework \uC0AC\uC6A9\uC790 \uCEE4\uC2A4\uD140 \uD56D\uBAA9 # //XitFramework \uC0AC\uC6A9\uC790 \uCEE4\uC2A4\uD140 \uD56D\uBAA9
# ############################################## # # ############################################## #
debug.result.log.trace=false
exception.log.trace=true exception.log.trace=true
# k byte # k byte
file.upload.allow.max-size: 2048 file.upload.allow.max-size: 2048

@ -120,7 +120,9 @@ Globals.Xit.Bbs.useAt = Y
# ############################################## # # ############################################## #
# //XitFramework \uC0AC\uC6A9\uC790 \uCEE4\uC2A4\uD140 \uD56D\uBAA9 # //XitFramework \uC0AC\uC6A9\uC790 \uCEE4\uC2A4\uD140 \uD56D\uBAA9
# ############################################## # # ############################################## #
debug.result.log.trace=false
exception.log.trace=true exception.log.trace=true
# k byte # k byte
file.upload.allow.max-size: 2048 file.upload.allow.max-size: 2048
file.upload.allow.ext= file.upload.allow.ext=

Loading…
Cancel
Save