Java Eclipse and jasper report: how to locate log4j.properties?

╄→尐↘猪︶ㄣ 提交于 2019-12-25 02:44:19

问题


I always get an error about this

log4j:WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory). log4j:WARN Please initialize the log4j system properly.

i dont know where is that log4j.properties is. is it downloadable? becouse i currently have zip pack named jasperreports-4.7.0,there are so many library there,but which one of it? please help me. i have no luck finding it in google. i have method that shows the table of my database

pubic void btnIreport(){

try{
    JasperDesign jd = JRXmlLoader.load("C:\\Users\\Nickz08\\Desktop\\test.jrpxml");
    String sql = "select * from tblStudentAccount order by name";
    JRDesignQuery newQuery = new JRDesignQuery();
    newQuery.setText(sql);
    jd.setQuery(newQuery);
    JasperReport jr = JasperCompileManager.compileReport(jd);
    JasperPrint jp = JasperFillManager.fillReport(jr, null,conn);
    JasperViewer.viewReport(jp);

}catch(Exception e){
    e.printStackTrace();

}}

回答1:


Read the following link how to create a log4j.properties file (No appenders could be found for logger(log4j)?)

you can add it any where you want, when you run your project, configure the classpath and add the location of the log4j.properties files by clicking on: Run->Run Configuration -> [classpath tab] -> click on user Entries -> Advanced -> Select Add Folder -> select the location of your log4j.properties file

and then -> OK -> run

and it should get loaded




回答2:


Try to create log4j.properties file in your src folder it might solve your issue.




回答3:


It has to be in your classpath. Check for it over there.



来源:https://stackoverflow.com/questions/20736858/java-eclipse-and-jasper-report-how-to-locate-log4j-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!