• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

PropertyConfigurator

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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 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

Can someone help me by telling where Iam going wrong ?

Thanks in advance for your help...

Cheers
Anirban
 
I'm so happy! And I wish to make this tiny ad happy too:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic