log4j:ERROR Could not read configuration file [log4j.properties].

Startup OpenMRS 1.7.1 (non-negotiable) and I receive the following error. Note that there was a log4j.xml in the WAR’s classes directory and to that I tried adding a log4j.properties but I still get the following error.

Where is a log4j.properties file supposed to go?

INFO - CodeFrequencyCache.doRecovery(200) |2016-06-14 09:23:20,285| begin recovery.
INFO - CodeFrequencyCache.doRecovery(230) |2016-06-14 09:23:20,286| end recovery of 0 items in 1ms.
INFO - SmsServiceManager.<init>(40) |2016-06-14 09:23:21,434| Computer is running linux. To make RXTX work properly, we must turning on serial polling
log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:120)
        at java.io.FileInputStream.<init>(FileInputStream.java:79)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:316)
        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:342)
        at org.smslib.helper.Logger.<init>(Logger.java:50)
        at org.smslib.helper.Logger.<clinit>(Logger.java:29)
        at org.smslib.Service.listSystemInformation(Service.java:113)
        at org.smslib.Service.initializeService(Service.java:103)
        at org.smslib.Service.<init>(Service.java:95)
        at org.smslib.Service.<clinit>(Service.java:90)
        at org.openmrs.module.messaging.sms.servicemanager.SmsServiceManager.<init>(SmsServiceManager.java:41)
        at org.openmrs.module.messaging.sms.SmsLibGateway.<init>(SmsLibGateway.java:36)
        at org.openmrs.module.messaging.domain.gateway.GatewayManager.<init>(GatewayManager.java:25)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
        at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:724)
        at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:791)
        at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:615)
        at org.openmrs.web.Listener.startOpenmrs(Listener.java:207)
        at org.openmrs.web.Listener.contextInitialized(Listener.java:146)

Thanks in advance.

From the error message, seems like the file isn’t looked up by loading it from the classpath, it’s hard to help figure out what’s wrong given that most developers no longer have a dev environment to debug 1.7.x issues since it reached end of life, might be tough for you get help with such an old version and that’s why we encourage people to use later versions.

Given that you’re already tampering with the war which is not such a great idea, you can try editing the web.xml file to add a context param for the log4j file location like here and see if that works

Thank you. That’s a great idea!