JDBCPoolAppender代码和其相关代码如下:
JDBCPoolAppender.java:
package common.log;
import java.sql.Connection;
import org.apache.log4j.spi.LoggingEvent;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Iterator;
import org.apache.log4j.spi.ErrorCode;
import org.apache.log4j.PatternLayout;
import common.sql.MyDB;
import common.sql.GeneralDb;
public class JDBCPoolAppender extends org.apache.log4j.jdbc.JDBCAppender {
private MyDB mydb = null;
protected String sqlname=""; //增加一个数据库jndiName的属性
protected Connection connection = null;
protected String sqlStatement = "";
/**
* size of LoggingEvent buffer before writting to the database.
* Default is 1.
*/
protected int bufferSize = 1;
public JDBCPoolAppender() {
super();
文章来源于领测软件测试网 https://www.ltesting.net/