打印本文 打印本文 关闭窗口 关闭窗口
[Java]log4j写SQL Server数据库日志的统一写法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数7062  更新时间:2007/11/14 13:08:37  文章录入:mintao  责任编辑:mintao
import org.apache.log4j.Level;

import org.apache.log4j.Logger;

import org.apache.log4j.PropertyConfigurator;

import org.apache.log4j.jdbc.*;

 

/*

    add for log4j: class Logger is the central class in the log4j package.

    we can do most logging operations by Logger except configuration.

    getLogger(...): retrieve a logger by name, if not then create for it.

    */

    static Logger logger = Logger.getLogger

            ( write2database.class.getName () ) ;

       

/*

        add for log4j: class BasicConfigurator can quickly configure the package.

        print the information to console.

        */

        PropertyConfigurator.configure ( "log4j2database.properties" ) ;

       

        logger.info ( "just test" ) ;

 

       运行起来,你就会看到有这样的sql语句被执行了:

       INSERT INTO jws_log  VALUES (''''2005-07-19 17:48:50'''', ''''main'''', ''''INFO'''', ''''write2database.main(write2database.java:33)'''', ''''just test'''', '''''''')

 

编写者

日期

关键词

上一页  [1] [2] [3] [4] [5] [6] [7]  下一页

打印本文 打印本文 关闭窗口 关闭窗口