logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anirban Das <ds.anir...@yahoo.co.in>
Subject Problem with PropertyConfigurator.Configure()
Date Thu, 16 Aug 2007 02:25:16 GMT
Hi,
      Iam using log4j (1.2.14) for logging in my webapp.


 The log4j.properties file under

C:\<app-context>\config\

The 
contents of the file is 

# text log 
file

log4j.logger.com.spcs.smt=debug,A2
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.file=C:\\WrkDir\\SMTWorkspace\\SMT_OCT07MAJ1_1\\logs\\smtGui.logs 

log4j.appender.A2.datePattern='.'yyyy-MM-dd
log4j.appender.A2.append=true
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%-5p 
%d{ISO8601} %c [%t] - %m%n



I have got an application 
Environment Configuration file which loads various config file for the app along with 
log4j.properties


Contents of 
"EnvConfiguration.java"



public class EnvConfiguration 
{

private static final Properties props = new Properties();
private 
static FileInputStream fis = null;
private static Logger logger = 
Logger.getLogger(EnvConfiguration.class);



static 
{
loadProps();
}

/**
* Load up the smtConf 
properties.
*/
public static void loadProps() {
String 
managedServerName = null;
String location = null;
try{
String os = 
System.getProperty("os.name");
if (os.startsWith("Windows")) { 


try{
props.load(new 
FileInputStream("C:/WrkDir/SMTWorkspace/SMT_OCT07MAJ1_1/config/log4j.properties"));
PropertyConfigurator.configure(props);
}catch(Exception 
ex){
ex.printStackTrace();
}

fis = new 
FileInputStream("C:/WrkDir/SMTWorkspace/SMT_OCT07MAJ1_1/config/smtConf.properties");

}else{

managedServerName 
= 
System.getProperty("weblogic.Name");
logger.debug("managedServerName="+managedServerName);
location 
= "config/" + 
managedServerName;
logger.debug("location="+location);

fis = new 
FileInputStream(location + "/smtConf.properties");

}

if (fis == 
null){
logger.error(location + "/smtConf.properties" + " not 
found");
throw new Exception(location + "/smtConf.properties" + " not 
found");
}

logger.debug("Loading SMT Configuration 
File");
props.load(fis);

}catch (Exception 
e){
e.printStackTrace();
}finally{
if(fis != null) {
try 
{
fis.close();
}catch (Exception f) 
{
f.printStackTrace();
}
}



}
}

I don't know y 
but Iam not able to see the app log to be present in the mentioned 
location.

Iam using tomcat5.5 and the only thing I see in the console 


log4j:WARN No appenders could be found for logger 
(com.spcs.smt.actions.TestAction).
log4j:WARN Please initialize the log4j 
system properly.

Iam using log4j1.2.8.jar and it is under 
<web-inf>/lib

I believe  I do not need to put log4j.properties file under classes if Iam using PropertyConfigurator.Confiure()

Can someone help me by telling where Iam going wrong 
?

Thanks in advance for your help...

Cheers
Anirban 




      Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message