• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in configuring log4j in struts  RSS feed

sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i have a class which has a static block and a static method.For the first time i call the static method in the class its strange that its excuting a part of the static block and entering the method later and agian turning back to static block.
but for the secon time when i call the static method in that class its fine that static block is not executed..
here is the code of the class which contains static block and static method
and propertyprovider is a class which contains methods for returning the path and .. which are in propeties file "plas.properties"
public class LogServices
private static String propFilename="plas.properties";
private static String file="vdvd";
System.out.println("Inside static block");
System.out.println("Inside static block of Plasma Log Services ");
file=PropertyProvider.getProperty(propFilename,"Log4jprops"); // here i am calling another method in another class to get some string from properties
System.out.println("\n File is ********************************** "+file);
catch(Exception e)
System.out.println("Exception encountered the following Exception ["+e.getMessage()+"]");
System.out.println("Finished static block");
public static Logger initLog()

Logger logger=Logger.getLogger(PlasmaLogServices.class);

System.out.println("File in method is:"+file);
return logger;
and in my main program i am calling this
LogServices.initLog(); and the output i observed on the screen is
Inside static block
Inside static block of Plasma Log Services
File in method is:vdvd
File is ********************************** log.properties
Finished static block
if u look at the output after " Inside static block of Plasma Log Services" (part of static block) its enetering method where " File in method is:vdvd" is printed .
After some debugging i came to know that if i remove the line
file=PropertyProvider.getProperty(propFilename,"Log4jprops"); and replace it by file="log.properties";(mean hardcoded) then the static block executes and later that method executes.

can any one pls help me in this regard???
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!