jinfeng_wang

G-G-S,D-D-U!

BlogJava 首页 新随笔 联系 聚合 管理
  400 Posts :: 0 Stories :: 296 Comments :: 0 Trackbacks
1)  SLF4J user manual
http://www.slf4j.org/manual.html

source:
 1package test;
 2
 3import org.slf4j.Logger;
 4import org.slf4j.LoggerFactory;
 5
 6public 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

 1package test;
 2
 3import java.sql.Connection;
 4import java.sql.DriverManager;
 5import java.sql.ResultSet;
 6import java.sql.Statement;
 7
 8public 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

 

posted on 2010-04-30 10:53 jinfeng_wang 阅读(1255) 评论(0)  编辑  收藏 所属分类: javaZZ

只有注册用户登录后才能发表评论。


网站导航: