LOG4J的配置文件log4j.properties已经放到WEB-INF\classes下面,下面是程序的内容:
---------------------------------------------------------------------------- public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SearchHibernateForm searchHibernateForm = (SearchHibernateForm) form;// TODO Auto-generated method stub
com.siyou.hibernate.TestTable testTable1 = new com.siyou.hibernate.TestTable();
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
tx = session.beginTransaction();
List l;
Logger logger = Logger.getLogger(this.getClass());
PropertyConfigurator.configure("log4j.properties"); try {
// String hqlDelete = "delete NativeTester";
Query query = session.createQuery("update TestTable as tt set tt.col2 = tt.col2 + '.com' where tt.col2 like '%21cn%'");
query.executeUpdate();
tx.commit();
logger.debug("hi");
}
catch (HibernateException e) {
if (tx != null) {
tx.rollback();
}
throw e;
}
finally {
session.close();
}
return mapping.findForward("success");
}---------------------------------------------------------------------------------------------
下面是LOG4J的配置文件的内容:
log4j.rootLogger = DEBUG, A1
log4j.appender.A1 = org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n请问何解?谢谢
---------------------------------------------------------------------------- public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SearchHibernateForm searchHibernateForm = (SearchHibernateForm) form;// TODO Auto-generated method stub
com.siyou.hibernate.TestTable testTable1 = new com.siyou.hibernate.TestTable();
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
tx = session.beginTransaction();
List l;
Logger logger = Logger.getLogger(this.getClass());
PropertyConfigurator.configure("log4j.properties"); try {
// String hqlDelete = "delete NativeTester";
Query query = session.createQuery("update TestTable as tt set tt.col2 = tt.col2 + '.com' where tt.col2 like '%21cn%'");
query.executeUpdate();
tx.commit();
logger.debug("hi");
}
catch (HibernateException e) {
if (tx != null) {
tx.rollback();
}
throw e;
}
finally {
session.close();
}
return mapping.findForward("success");
}---------------------------------------------------------------------------------------------
下面是LOG4J的配置文件的内容:
log4j.rootLogger = DEBUG, A1
log4j.appender.A1 = org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout = org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern = %-4r [%t] %-5p %c %x - %m%n请问何解?谢谢
提示以下出错:log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources).
log4j:WARN Please initialize the log4j system properly.
这个是找不到文件
use it as a servlet;
make the servlet startup when the jsp container start;