提示No XML at the specified location: http://jakarta.apache.org/log4j/问题

93 阅读1分钟

控制台提示错误信息:

log4j:WARN No appenders could be found for logger (com.*.init.Init). log4j:WARN Please initialize the log4j system properly. log4j:WARN See logging.apache.org/log4j/1.2/f… for more info.

问题原因:

在测试类中的init方法中没有配置log4j.xml

@Before
public void init(){
    //没有配置scf_log4j.xml
    //DOMConfigurator.configure("src/main/resources/config/scf_log4j.xml");
    new Init().init();
}

解决:

sudo mkdir -p /opt/web/arch_open_web/wf/logs/

//这里的$代表自定义的名称
sudo touch /opt/scf2/log/$/$.log
sudo touch /opt/web/arch_open_web/wf/logs/job-register.log
sudo touch /opt/web/arch_open_web/wf/logs/job-executor.log

//这里的$代表自定义的名称
sudo chmod 666 /opt/scf2/log/$/$.log
sudo chmod 666 /opt/web/arch_open_web/wf/logs/job-register.log
sudo chmod 666 /opt/web/arch_open_web/wf/logs/job-executor.log

//添加到init方法中
DOMConfigurator.configure("src/main/resources/config/scf_log4j.xml");