1.standalone.conf JAVA_OPTS 변수 또는 start 스크립트에 아래 설정 추가

-Dlog4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator

 

2.module 설정

 ...modules/net/sf/log4jdbc/main/log4jdbc-log4j2-jdbc4-1.12.jar
 ...modules/net/sf/log4jdbc/main/module.xml

module.xml

<?xml version='1.0' encoding='UTF-8'?>
<module xmlns="urn:jboss:module:1.1" name="net.sf.log4jdbc">
    <resources>
        <resource-root path="log4jdbc-log4j2-jdbc4-1.12.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="org.slf4j"/>
        <module name="com.h2database.h2"/>
        <module name="com.oracle"/>
        <module name="org.mariadb"/>
    </dependencies>
</module>

(com.oracle - Orlacle jdbc-dirver  / org.mariadb - mariadb driver)

 

3.standalone*.xml 설정

......
        <subsystem xmlns="urn:jboss:domain:datasources:5.0">
            <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:log4jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>log4jdbc</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:/OracleDS" pool-name="OracleDS">
                    <connection-url>jdbc:log4jdbc:oracle:thin:@localhost:1521:orcalesid</connection-url>
                    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                    <driver>log4jdbc</driver>
                    <security>
                        <user-name>test</user-name>
                        <password>test</password>
                    </security>
                    <validation>
                        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
                        <background-validation>true</background-validation>
                        <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
                        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
                    </validation>
                </datasource>
                <datasource jndi-name="java:jboss/datasources/JpetStoreDS" pool-name="jpetstore">
                    <connection-url>jdbc:log4jdbc:mariadb://192.168.0.163:3306/jpetstore</connection-url>
                    <driver>log4jdbc</driver>
                    <security>
                        <user-name>test</user-name>
                        <password>test</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name="oracle" module="com.oracle"/>
                    <driver name="mariadb" module="org.mariadb"/>
                    <driver name="log4jdbc" module="net.sf.log4jdbc"/>
                </drivers>
            </datasources>
        </subsystem> 

...... 

 

4.Connection 테스트

 -테스트 환경상 Oracle DB 접속은 불가능하여 Maria DB로 테스트 수행하였습니다.

[standalone@192.168.0.10:10990 /] data-source test-connection-in-pool --name=jpetstore
true
[standalone@ 192.168.0.10:10990 /] data-source test-connection-in-pool --name=ExampleDS
true 


로그화면

2019-11-08 16:25:25,502 INFO  [jdbc.connection] (management-handler-thread - 1) 1. Connection opened
2019-11-08 16:25:25,502 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.new Connection returned
2019-11-08 16:25:25,510 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.getTransactionIsolation() returned 4
2019-11-08 16:25:25,510 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.isReadOnly() returned false
2019-11-08 16:25:25,512 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.getMetaData() returned org.mariadb.jdbc.MariaDbDatabaseMetaData@54d3ea99
2019-11-08 16:25:25,512 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.getMetaData() returned org.mariadb.jdbc.MariaDbDatabaseMetaData@4eaeff49
2019-11-08 16:25:25,512 INFO  [jdbc.audit] (management-handler-thread - 1) 1. Connection.getMetaData() returned org.mariadb.jdbc.MariaDbDatabaseMetaData@42a42903
2019-11-08 16:25:37,122 INFO  [jdbc.connection] (management-handler-thread - 1) 2. Connection opened
2019-11-08 16:25:37,124 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.new Connection returned
2019-11-08 16:25:37,128 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.getTransactionIsolation() returned 2
2019-11-08 16:25:37,128 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.isReadOnly() returned false
2019-11-08 16:25:37,129 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.getMetaData() returned dbMeta0: conn0: url=jdbc:h2:mem:test user=SA
2019-11-08 16:25:37,129 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.getMetaData() returned dbMeta1: conn0: url=jdbc:h2:mem:test user=SA
2019-11-08 16:25:37,130 INFO  [jdbc.audit] (management-handler-thread - 1) 2. Connection.getMetaData() returned dbMeta2: conn0: url=jdbc:h2:mem:test user=SA 

+ Recent posts