출처
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=kalpa730&logNo=140126860422
과거의 JBOSS 환경에 현재 자주 사용하는 log4jdbc DriverSpy 를 사용하기 위한 설정 방법
JBOSS 환경
- JBOSS 4.0.1
- JDK 1.4
필요라이브러리
1. log4j-1.2.15.jar
2. log4jdbc3-1.2beta2.jar ( jdk 1.4 이므로 log4jdbc3 을 사용 , 1.5 이상은 log4jdbc4 사용)
3. slf4j-log4j12-1.6.1.jar
4. slf4j-api-1.6.1.jar
설치방법
1. JBOSS log4j 제거하기
- /jboss-4.0.1/lib/log4j-boot.jar 라이브러리 제거
- log4j-1.2.15.jar 와 중복 충돌 남
2. log4j-1.2.15.jar 라이브러리 복사해 넣기 /jboss-4.0.1/lib/
3. log4jdbc 라이브러리 추가하기
- /jboss-4.0.1/server/default/lib
- log4jdbc3-1.2beta2.jar , slf4j-log4j12-1.6.1.jar, slf4j-api-1.6.1.jar
4. DataSource 드라이버 설정 변경하기
- /jboss-4.0.1/server/default/deploy
- ***-ds.xml
- 변경전
<datasources>
<local-tx-datasource>
<jndi-name>***</jndi-name>
<connection-url>jdbc:oracle:thin:@***.***.***.***:1521:TBNM</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>***</user-name>
<password>***</password>
</local-tx-datasource>
</datasources>
- 변경후
<datasources>
<local-tx-datasource>
<jndi-name>***</jndi-name>
<connection-url>jdbc:log4jdbc:oracle:thin:@***.***.***.***:1521:TBNM</connection-url>
<driver-class>net.sf.log4jdbc.DriverSpy</driver-class>
<user-name>***</user-name>
<password>***</password>
</local-tx-datasource>
</datasources>
5. log4j.xml 파일 설정하기
- /jboss-4.0.1/server/default/config
- logger 설정 추가 1, 2 둘 중 선택해서 알아서 설정하기
1>
<category name="jdbc.sqlonly">
<priority value="DEBUG"/>
</category>
<category name="jdbc.connection">
<priority value="ERROR"/>
</category>
<category name="jdbc.debug">
<priority value="ERROR"/>
</category>
<category name="jdbc.resultset">
<priority value="ERROR"/>
</category>
<category name="jdbc.sqltiming">
<priority value="ERROR"/>
</category>
<category name="jdbc.audit">
<priority value="ERROR"/>
</category>
2>
<logger name="jdbc.sqlonly" additivity="false">
<level value="DEBUG" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>
<logger name="jdbc.sqltiming" additivity="false">
<level value="ERROR" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>
<logger name="jdbc.resultset" additivity="false">
<level value="ERROR" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>
<logger name="log4jdbc.debug" additivity="false">
<level value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>
<logger name="jdbc.connection" additivity="false">
<level value="ERROR" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>
<logger name="jdbc.audit" additivity="false">
<level value="ERROR" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="DRFA" />
</logger>