log4jdbc and hibernate

log4jdbc and hibernate
1)  SLF4J user manual
http://www.slf4j.org/manual.html

source:
 1 package  test;
 2
 3 import  org.slf4j.Logger;
 4 import  org.slf4j.LoggerFactory;
 5
 6 public   class  Test  {
 7    final static Logger logger = LoggerFactory.getLogger(Test.class);
 8    
 9    public static void main(String[] args) {
10        logger.error("test");
11    }

12
13}

14

jar file:
slf4j - log4j12 - 1.5 . 8 .jar
slf4j
- api - 1.5 . 8 .jar
log4j
- 1.2 . 15 .jar

2) Analyzing JDBC Logs with LOG4JDBC
http://www.cubrid.org/analyzing_jdbc_logs#_Toc234038379

 1 package  test;
 2
 3 import  java.sql.Connection;
 4 import  java.sql.DriverManager;
 5 import  java.sql.ResultSet;
 6 import  java.sql.Statement;
 7
 8 public   class  jdbcsample  {
 9    static public void main(String[] argc) throws Exception {
10        String connectionURL = "jdbc:log4jdbc:mysql://127.0.0.1:3306/sampledb";
11
12        Class.forName("net.sf.log4jdbc.DriverSpy").newInstance();
13        Connection connection = DriverManager.getConnection(connectionURL,
14                "root""1234");
15
16        Statement statement = connection.createStatement();
17        ResultSet rs = statement.executeQuery("SELECT * FROM customers");
18
19        while (rs.next()) {
20            System.out.println(rs.getString(1));
21        }

22        rs.close();
23
24    }

25}

26

jar file:
add the jar file:
log4jdbc3
- 1 .2beta1.jar
mysql
- connector - java - 5.1 . 12 - bin.jar

3)Hibernate SQL Logging: log4jdbc / Haciendo log de SQL con Hibernate: log4jdbc
http://softdevbuilttolast.wordpress.com/2010/02/22/hibernate-sql-logging-log4jdbc-haciendo-log-de-sql-con-hibernate-log4jdbc/

//confgi the hibernate with the proxy connection

hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=net.sf.log4jdbc.DriverSpy
hibernate.connection.url=jdbc:log4jdbc:mysql://localhost:3306/SAMPLEDB
hibernate.connection.username=root
hibernate.connection.password=1234
hibernate.show_sql=false

 

你可能感兴趣的:(log4jdbc and hibernate)