SPRING
2020.10.21 / 11:07

[JEUS] log4jdbc ̵ -

߼
õ 11

 ÿ 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. 

      

 

3. log4jdbc-remix.jar

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 ִµ Ÿ .

 

4. log4j.jar

  α ̺귯.   log4j α Ѵ.

 

 * jog4jdbc-log4j2 VS log4jdbc

  => 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 - |------|-------|----------|-----|--------------------|-----|-----|-------|

 

  .