- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
ServletContextListener 등록하기. 본문
ServletContextListener 를 어떻게 등록하나?
log4j.properties 파일에서 System Property 를 참조하도록 설정을 해놓았는데, 따라서 log4j.properties 파일을 읽기 전에 System Property를 설정해야 할 필요가 있었다.
[참고] http://stackoverflow.com/questions/216781/log4j-configuring-a-web-app-to-use-a-relative-path
Servlet 의 init() 메서드 안에서 System Property를 설정하는 것은 log4j.properties 파일을 읽고 난 다음이다.
따라서 다음과 같이 ServletContextListener 를 상속받은 클래스를 web.xml 에서 listener 로 등록해주면 된다.
만약 이렇게 해도 log4j.properties 파일을 먼저 읽게 된다면, log4j.properties 파일의 이름을 바꿔야 한다.
default 이름을 쓰지 말고, 이름을 바꿔서 web.xml 에서 Spring에서 제공해주는 Log4jConfigListener를 등록해줘야 한다.
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
< ServletContextListener를 web.xml에 등록하는 방법 >
http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/
<web-app ...>
<listener>
<listener-class>com.example.web.AppServletContextListener</listener-class>
</listener>
</web-app>
'Java' 카테고리의 다른 글
이클립스 3.6에서 SVN 단축키가 먹지 않을때 (0) | 2013.03.28 |
---|---|
[eclipse] Interface를 구현한 클래스 쉽게 찾아가기 (0) | 2013.03.27 |
이클립스 플러그인 개발 환경(PDE) - OMA DM Simulator (0) | 2013.03.27 |
[osgi] Maven Bundlor 플러그인 설정 (0) | 2013.01.14 |
Maven - Archetype Catalog 추가하기 (0) | 2013.01.14 |