gpt4 book ai didi

java - 如何恢复此错误: log4j:WARN No appenders could be found for logger (net. sf.jasperreports.extensions.ExtensionsEnvironment)

转载 作者:行者123 更新时间:2023-12-01 19:39:54 26 4
gpt4 key购买 nike

我尝试使用 ireport 制作报告,但遇到此问题:

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

My source:

private URL[] reports = new URL[]{
getClass().getResource("/Laporan/LapGuru.Jasper"),
getClass().getResource("/Laporan/LapGuruByNIP.Jasper"),};
private URL urlCurrent;

try{

Map parameter = new HashMap();

parameter.put("nip",this.txtNIP.getText());
InputStream os = null;
os = urlCurrent.openStream();
JasperReport jReport = (JasperReport)JRLoader.loadObject(os);
JasperPrint jPrint = JasperFillManager.fillReport(jReport, parameter, ClassDB.getkoneksi());
JRViewer viewer = new JRViewer(jPrint);
viewer.setOpaque(true);
viewer.setVisible(true);
jScrollPane1.add(viewer);
jScrollPane1.setViewportView(viewer);

} catch (Exception ex)
{
System.out.println(ex);
}

最佳答案

确保类路径中有 log4j.properties 文件。如果您想在启动 Java 时将系统属性添加到命令行,还可以使用其他选项来配置 log4j,如下所示:

-Dlog4j.configuration=file:///path/to/your/log4j.properties

查看链接http://logging.apache.org/log4j/1.2/manual.html#defaultInit

关于java - 如何恢复此错误: log4j:WARN No appenders could be found for logger (net. sf.jasperreports.extensions.ExtensionsEnvironment),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14142621/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com