主题:hibernate中Log4j初始化问题?加分
小弟用eclipse建了一个简单的hibernate的例子,然后编写一个类如下:
package helun;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class www {
public static void main(String[] args) {
try{Configuration config=new Configuration();
SessionFactory sf=config.buildSessionFactory();
Session s=sf.openSession();
Transaction tx=s.beginTransaction();
Test test=new Test();
test.setName("ddd");
test.setPwd("ff");
s.save(test);
tx.commit();
s.close();
System.out.println("success");
}catch(Exception ex)
{
System.out.println("fail");
}
}
}
进行测试,可是每次运行结果如下:
fail
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
是不是要配置log4j,如何配呢,它要示的包应放在哪些目录下面,请高手详细指点一下,谢谢
package helun;
import org.hibernate.*;
import org.hibernate.cfg.*;
public class www {
public static void main(String[] args) {
try{Configuration config=new Configuration();
SessionFactory sf=config.buildSessionFactory();
Session s=sf.openSession();
Transaction tx=s.beginTransaction();
Test test=new Test();
test.setName("ddd");
test.setPwd("ff");
s.save(test);
tx.commit();
s.close();
System.out.println("success");
}catch(Exception ex)
{
System.out.println("fail");
}
}
}
进行测试,可是每次运行结果如下:
fail
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
是不是要配置log4j,如何配呢,它要示的包应放在哪些目录下面,请高手详细指点一下,谢谢