| 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] 下一页
|