복붙노트

[SPRING] Spring : 표준 로깅 측면 (인터셉터)

SPRING

Spring : 표준 로깅 측면 (인터셉터)

이처럼 Spring 프레임 워크를 사용하여 로깅을위한 커스텀 애스펙트를 생성하는 방법에 대한 많은 예제를 발견했으나이 상황과 질문을 위해 표준 / 공통 스프링 구현을 찾지 못했습니다. Spring에서 로깅 측면에 대한 표준 구현이 있습니까?

해결법

  1. ==============================

    1.네, 있습니다!

    네, 있습니다!

    <bean id="customizableTraceInterceptor" class="org.springframework.aop.interceptor.CustomizableTraceInterceptor">
        <property name="enterMessage" value="Entering $[methodName]($[arguments])"/>
        <property name="exitMessage" value="Leaving $[methodName](): $[returnValue]"/>
    </bean>
    <aop:config>
        <aop:advisor advice-ref="customizableTraceInterceptor" pointcut="execution(public * BankAccountServlet.*(..))"/>
    </aop:config>
    

    CustomizableTraceInterceptor API를 확인하면 몇 개의 자리 표시자가있는 입력 / 종료 / 예외 메시지를 별도로 정의 할 수 있습니다.

  2. ==============================

    2.다음은 AOP를 통해 로깅을 수행하는 프레임 워크 목록입니다.

    다음은 AOP를 통해 로깅을 수행하는 프레임 워크 목록입니다.

    http://aspect4log.sf.net - slf4j 및 @Log 주석을 통해 매우 멋진 로깅을 수행합니다. SpringAOP과 AspectJ를 통해 작업 할 수있다. AspectJ를 사용하면 private 메소드와 생성자에서도 작동하며 클래스가 Spring Bean이 될 필요가 없다. 매우 사용하기 쉽고, 5 분 이내에 프로젝트를 실행할 수있었습니다.

    http://loggifier.unkrig.de - java.util.logging을 통해 로깅합니다. 너무 복잡하고 잘 작성된 문서가 아니지만 이미 jar / war / ear 파일을 컴파일 할 수 있다고 주장합니다!

    AbstractTraceInterceptor (SpringAOP에서 제공)이며 하위 클래스 인 SimpleTraceInterceptor 및 CustomizableTraceInterceptor입니다. 로깅 구성은 클래스와 별도로 수행됩니다. commons-logging을 통한 로그. SpringAOP 용으로 설계되었으므로 Spring Beans (그리고 Spring Bean public 메서드에서만)로 작업해야한다.

  3. from https://stackoverflow.com/questions/7302090/spring-standard-logging-aspect-interceptor by cc-by-sa and MIT license