2월, 2016의 게시물 표시

AOP 로깅과 성능측정 Interceptor

출처 : http://whiteship.tistory.com/1099 디버그 인터셉터 :: org.springframework.aop.interceptor.DebugInterceptor 성능 측정 인터셉터 :: org.springframework.aop.interceptor.PerformanceMonitorInterceptor 사용법은 ProxyFactoryBean으로 간단하게 설정하여 사용할 수 있습니다. < bean id="proxy"         class="org.springframework.aop.framework.ProxyFactoryBean">         <property name="target" ref="" />         <property name="interceptorNames">             <list>                 <value>global*</value>             </list>         </property> </bean> <bean id="global_debug"         class="org.springframework.aop.interceptor.DebugInterceptor" /> <bean id="global_performance"         class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor" /> <bean id="xstreamMarshaller"            class="com.namo.pt.common.oxm.CustomXStream

웹상에 퍼져있는 slf4j 연동관련 정리

일반적으로 사용되는 Facade 로깅 라이브러리는 JCL(http://commons.apache.org/logging/), SLF4J(http://www.slf4j.org/) 두개인거 같다. 이 두개의 라이브러리 모두 실제 로깅처리는 log4j 같은 실제 구현라이브러리들에 처리를 맡기는 구조이다. 자 그럼 이 두개의 라이브러리 중에 어떤걸 주로 쓰느냐 하면 SLF4J 라이브러리 이다. JCL은 실제 로그 구현체를 선택하는 시점이 런타임이라 다중 클레스로더(ClassLoader)를 사용하는 환경에서 문제가 될수 있고 런타임시점에 동작하기 때문에 성능상에 이슈 또한 있다고 한다. 더불어서 SLF4J는 로그 출력시 포멧팅을 지원하기 때문에 JCL을 사용할때의 아래와 같은 불편함을 해결해준다. 성능상 심하게는 30배정도 더 빠르다고 한다. 믿거나 말거나..-_- EX) JCL if( log.isDebugEnabled() ) {    log.debug(name + "님 안녕하세요"); } EX) SLF4J logger.deubg("{}님 안녕하세요", name); 이 두개의 예들은 같은 결과를 만들지만 보다시피 JCL을 사용할때 로그레벨을 확인하는 IF문이 SLF4J에는 빠져있다. 또한 SLF4J는 해당로그 레벨에서만 인자로 주어진(name) 값을 적용하기 때문에 로그레벨을 더이상 걱정할 필요가 없 Log4j-slf4j연동 log4j가 설정되어있다는 기준으로 보았을때 slf4j 는 퍼사드 객체임을 명심해야 한다. 그자체로 로깅기능보다는 메이븐 설정 <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-api</artifactid>             <version>${o

[CentOS] Sonatype Nexus 이사하기(출처 - http://bestist.pe.kr/author/bestist)

$ NEXUS _HOME을 참고하여 sonatype-work 폴더를 백업한다.(설치계정에 sonatype-work 폴더에 생성된다) 1 $ tar cvf sonatype - work . tar sonatype - work / sonatype 사이트에서  nexus  파일을 받아 설치준비를 한다. 1 2 3 $ wget http : //www.sonatype.org/downloads/ nexus -latest-bundle.tar.gz $ tar xvf nexus - latest - bundle . tar . gz 백업 받았던 sonatype-work.tar를 working directory를 지정하여 풀어준후 환경설정을 한다. 1 2 3 4 $ vi . / conf / nexus . properties # Nexus section nexus - work = $ { bundleBasedir } / . . / sonatype - work / nexus nexus 는 root 사용자로 실행할 경우 보안이슈가 있으므로 별도로 사용자를 만들어 실행하는것을 추천한다. 1 2 3 4 $ useradd nexus # nexus 폴더의 권한을 nexus 에게 준다. $ chown - R nexus : nexus nexus nexus  실행 스크립트를 /etc/init.d로 복사한다. 1 $ cp . / bin / nexus / etc / init . d / nexus  실행 스크립트를 수정하며, 이때 v