import org.apache.log4j.Category;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.jdbc.*;
public class Write2Database{
public static void main(String[] args){
static Logger logger = Logger.getLogger
( write2database.class.getName () ) ;
PropertyConfigurator.configure ( "log4j2database.properties" ) ;
logger.info ( "test" ) ;
}
}
运行起来,你就会看到有这样的sql语句被执行了:
INSERT INTO jws_log VALUES ('2006-01-18 17:50:22', 'main', 'INFO',
'Wite2Database.main(Write2Database.java:18)', 'test', '')
文章来源于领测软件测试网 https://www.ltesting.net/