Skip to Content
0
Former Member
Jun 15, 2009 at 04:11 AM

Unable to read configuration file

300 Views

Hi,

I'm implementing Log4j in my EJB. Now i'm having problem to read/locate my log4j.properties file. I not sure the path i put my log4j.properties. I did try in few places but seem not working also. My EJB is packaged with a WAR in an EAR file.

Currently i'm placing my log4j.properties file in the root folder of my EJB. (CustomEJB>log4j.properties)

This is my code in my EJB

....
public class GatewayBean implements SessionBean {
static Logger logger =  Logger.getLogger("GatewayBean.class");
public String[] testLog() {
try{
	PropertyConfigurator.configure("log4j.properties");
	logger.info(new Date() + " testLog");
	logger.info(new Date() + " Testing for logging");
}catch (Exception e){
e.printStackTrace();
}
}
...

When it try to load the properties file, it unable to find. This is the error that i got.

log4j:ERROR Could not read configuration file [log4j.properties].#
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)#
log4j:ERROR Ignoring configuration file [log4j.properties].#

No problem for WEB application. But only for EJB. I try to put in the EJB>META-INF, also not working. So i not sure where to put the properties file and it can load. I try to include in my Java Build Path but cannot as is only can include .jar n .zip file.

Thanks in advance for the help.

-


Just now i google for this and i try to get my the path when running this program. I realized the path is \usr\X01\DVEBMGS01\j2ee\cluster\server0

So i put the log4j.properties file in that path and now it able to read it. But i don't think this is the correct way as it should be in the deployment file. What i think is weird that isn't the path should be at \usr\X01\DVEBMGS01\j2ee\cluster\server0\apps\sap.com\GatewayEAR......?

Edited by: Adrian Chan on Jun 15, 2009 8:53 AM