[JEUS] log4jdbc ¼³Á¤ °¡À̵å - ±ÃÇÕ
º» Æ÷½ºÆÿ¡¼´Â Log4JDBC ¼³Á¤ ¹æ¹ý¿¡ ´ëÇØ °¡À̵å Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù.
1. Log4jdbc µå¶óÀ̹ö
log4jdbc is a Java JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information) for other JDBC drivers using theSimple Logging Facade For Java (SLF4J) logging system.
2. slf4j.jar
logger¶óÀ̺귯¸®¸¦ ¼±ÅÃÇØÁÖ´Â interfaceÇÁ·Î±×·¥À¸·Î »ý°¢ÇÏ¸é µÈ´Ù.
( The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time.)
SLF4J does not rely on any special class loader machinery. In fact, each SLF4J binding is hardwired at compile time to use one and only one specific logging framework. For example, the slf4j-log4j12-1.7.5.jar binding is bound at compile time to use log4j. In your code, in addition to slf4j-api-1.7.5.jar, you simply drop one and only one binding of your choice onto the appropriate class path location. Do not place more than one binding on your class path. Here is a graphical illustration of the general idea.
What was log4jdbc-remix?
log4jdbc-remix was an experimental fork of log4jdbc that:
Can log result sets as tables
Can be configured as a Spring Datasource
Can use a plugable SQL formatter
Is available in the sonatype maven repository. https://oss.sonatype.org/index.html#nexus-search;quick~log4jdbc
Only supports Java 6 and above (log4jdbc which also supports java 1.4 and 1.5)
Its now superseded by log4jdbc-log4j2 at https://code.google.com/p/log4jdbc-log4j2/ which also supports JDBC 4.1 (Java 7), JDBC 4 (Java 6), JDBC 3 (Java 5). The original log4jdbc also supports java 1.4.
=> reultsetÀ» table¹æ½ÄÀ¸·Î º¸¿©ÁִµîÀÇ ±âŸ ±â´ÉÀÌ ÀÖÀ½.
º¸ÆíÀûÀ¸·Î ¾²´Â ·Î±ë ¶óÀ̺귯¸®. ¿©±â ¿¹¿¡¼´Â log4j¸¦ ÅëÇØ ·Î±ë ¼³Á¤À» ÇÑ´Ù.
=> log4jdbc-log4j2´Â log4j2¸¦ Áö¿øÇϱâ À§ÇÑ °ÍÀÌ´Ù.
log4jdbc-log4j2 is a modification of log4jdbc to natively use Log4j 2 (or SLF4J as usual), that supports JDBC 4.1 to JDBC 3, includes all the improvements of log4jdbc-remix, and provides new improvements on its own. log4jdbc-log4j2: |
log4j + log4jbc |
log4j2 + log4jdbc-log4j2 |
5. ¶óÀ̺귯¸® ´Ù¿î
log4j ¶óÀ̺귯¸® : http://logging.apache.org/log4j/1.2/download.html
slf4j ¶óÀ̺귯¸® : http://slf4j.org/download.html
log4jdbc ¶óÀ̺귯¸®: https://code.google.com/p/log4jdbc/
log4jdbc-remix : http://code.google.com/p/log4jdbc-remix/
https://oss.sonatype.org/index.html#nexus-search
quick~log4jdbc-remix (2.7¹öÀüÀÌ ¾ÈÁ¤ÀûÀ̶ó°í ÇÔ)
ÇöÀç(2013.11.23) log4jdbc»çÀÌÆ®¿¡ °¡º¸¸é. final ¹öÀüÀÌ 1.2Àε¥, À̳ѰúÀÇ ±ÃÇÕÀº sfl4j12.1.5ÀÓÀ» ¾Ë ¼ö ÀÖ°í, À̳ѰúÀÇ log4j±ÃÇÕÀº log4j12.1.5 ÀÌ´Ù.
Áï ¾Æ·¡¿Í °°Àº ¶óÀ̺긮·¯ °¡ ÇÊ¿äÇÏ´Ù.
log4j-1.2.15.jar log4jdbc4-1.2.jar slf4j-api-1.5.0.jar slf4j-log4j12-1.5.0.jar log4jdbc-remix-0.2.7.jar(¿É¼Ç) |
* log4jdbc4-1.2.jar, log4jdbc-remix-0.2.7.jar 2°³ ¸ðµÎ »ç¿ëÇÏ¸é ¾ÈµÊ.
sql°á°ú¸¦ tableÇüÅ·Πº¸¿©ÁÖ±â À§Çؼ´Â log4jdbc-remix-0.2.7.jar¸¸
»ç¿ëÇÏ¸é µÈ´Ù.
* log4jdbc-remix´Â JDK1.6¿¡¼ Áö¿ø
6. JEUSMain.xml
<database> <vendor>others</vendor> <export-name>datasource</export-name> <data-source-class-name>jeus.jdbc.driver.blackbox.BlackboxConnectionPoolDataSource</data-source-class-name> <data-source-type>ConnectionPoolDataSource</data-source-type> <user>scott</user> <password>tiger</password> <property> <name>URL</name> <type>java.lang.String</type> <value>jdbc:log4jdbc:oracle:thin:@nrson:1521:orcl</value> </property>
<property> <name>DriverClassName</name> <type>java.lang.String</type> <value>net.sf.log4jdbc.DriverSpy</value> </property> <connection-pool> <pooling> <min>10</min> <max>40</max> <step>5</step> <period>300000</period> </pooling> <wait-free-connection> <enable-wait>true</enable-wait> <wait-time>10000</wait-time> </wait-free-connection> <check-query>SELECT 1 FROM dual</check-query> <check-query-period>300000</check-query-period> </connection-pool> </database> |
7. log4j¼³Á¤
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss}] %-5p: %c - %m%n" /> </layout> </appender>
<!-- infoºÎÅÍ Àû¿ë table»ç¿ë½Ã --> <logger name="jdbc.resultsettable" additivity="false"> <level value="info" /> <appender-ref ref="console" /> </logger>
<!-- sql ·Î±ë --> <logger name="jdbc.sqlonly" additivity="false"> <level value="info" /> <appender-ref ref="console" /> </logger>
<logger name="jdbc.audit" additivity="false"> <level value="warn" /> <appender-ref ref="console" /> </logger>
<!-- infoºÎÅÍ Àû¿ë ±âº»ÀûÀÎ resultset--> <!-- resultsettable ¸¸ »ç¿ëÇϱâ À§Çؼ ·Î±×·¹º§Àº warning½ÃŲ´Ù. resurtsetÀÌ Áߺ¹µÊ --> <logger name="jdbc.resultset" additivity="false"> <level value="warn" /> <appender-ref ref="console" /> </logger>
<!-- ¼öÇà½Ã°£À» Âï´Â´Ù--> <logger name="jdbc.sqltiming" additivity="false"> <level value="info" /> <appender-ref ref="console" /> </logger> <root> <priority value="warn" /> <appender-ref ref="console" /> </root> </log4j:configuration>
|
*log4jdbc-remix¸¦ »ç¿ëÇÏ°í,jdbc.resultsettabl ·Î°Å»ç¿ë½Ã Á¤»óÀûÀ¸·Î sql °á°ú°¡ table·Î º¸ÀÌÁö ¾ÊÀ» ¶§.
=>log4jdbc¿Í log4jdbc-remix°¡ °°ÀÌ ·ÎµùµÇ¸é¼ log4jdbc°¡ ¸ÕÁ® ·ÎµùµÇ¼ ¹®Á¦´Ù Ŭ·¡½º Æнº·Î ÀâÀ¸¸é µÈ´Ù..
8. sql¼öÇàÈÄ ·Î±× ³»¿ë
2013.11.23 01:32:05][2][b288] [container1-56] [JDBC-0378] Data source [datasource] is configured with DEPRECATED BlackBoxDataSource driver. Please configure this to use proper ConnectionPoolDataSource of the database's driver. [2013.11.23 01:32:06][2][b288] [container1-56] [JMX-0011] create MBean : JEUS:j2eeType=JDBCDataSource,JMXManager=nrson_container1,JeusManager=nrson,J2EEServer=nrson_container1, JDBCResource=nrson_container1,name=datasource [2013.11.23 01:32:06][2][b288] [container1-56] [JMX-0011] create MBean : JEUS:j2eeType=JDBCDriver,JMXManager=nrson_container1,JeusManager=nrson,J2EEServer=nrson_container1, JDBCResource=nrson_container1,JDBCDataSource=datasource,name=others [2013.11.23 01:32:06][2][b288] [container1-56] [JMX-0011] create MBean : JEUS:j2eeType=JDBCConnectionInfo,JMXManager=nrson_container1,JeusManager=nrson,J2EEServer=nrson_container1, JDBCResource=nrson_container1,JDBCDataSource=datasource,name=datasource [2013-11-23 01:32:06] INFO : jdbc.sqlonly - SELECT 1 FROM dual [2013-11-23 01:32:06] INFO : jdbc.sqltiming - SELECT 1 FROM dual {executed in 22 msec} [2013-11-23 01:32:06] INFO : jdbc.sqlonly - select * from emp [2013-11-23 01:32:06] INFO : jdbc.sqltiming - select * from emp {executed in 15 msec} [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |------|-------|----------|-----|--------------------|-----|-----|-------| [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |EMPNO |ENAME |JOB |MGR |HIREDATE |SAL |COMM |DEPTNO | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |------|-------|----------|-----|--------------------|-----|-----|-------| [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7369 |SMITH |CLERK |7902 |1980-12-17 00:00:00 |800 |null |20 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7499 |ALLEN |SALESMAN |7698 |1981-02-20 00:00:00 |1600 |300 |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7521 |WARD |SALESMAN |7698 |1981-02-22 00:00:00 |1250 |500 |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7566 |JONES |MANAGER |7839 |1981-04-02 00:00:00 |2975 |null |20 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7654 |MARTIN |SALESMAN |7698 |1981-09-28 00:00:00 |1250 |1400 |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7698 |BLAKE |MANAGER |7839 |1981-05-01 00:00:00 |2850 |null |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7782 |CLARK |MANAGER |7839 |1981-06-09 00:00:00 |2450 |null |10 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7788 |SCOTT |ANALYST |7566 |1987-04-19 00:00:00 |3000 |null |20 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7839 |KING |PRESIDENT |null |1981-11-17 00:00:00 |5000 |null |10 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7844 |TURNER |SALESMAN |7698 |1981-09-08 00:00:00 |1500 |0 |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7876 |ADAMS |CLERK |7788 |1987-05-23 00:00:00 |1100 |null |20 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7900 |JAMES |CLERK |7698 |1981-12-03 00:00:00 |1000 |null |30 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7902 |FORD |ANALYST |7566 |1981-12-03 00:00:00 |3000 |null |20 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |7934 |MILLER |CLERK |7782 |1982-01-23 00:00:00 |1300 |null |10 | [2013-11-23 01:32:06] INFO : jdbc.resultsettable - |------|-------|----------|-----|--------------------|-----|-----|-------|
|
´ÙÀ½¿¡ ºËÁÒ.