File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes problem in configuring log4j in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in configuring log4j in struts" Watch "problem in configuring log4j in struts" New topic

problem in configuring log4j in struts

sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
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 ""
public class LogServices
private static String propFilename="";
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 **********************************
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="";(mean hardcoded) then the static block executes and later that method executes.

can any one pls help me in this regard???
I agree. Here's the link:
subject: problem in configuring log4j in struts
It's not a secret anymore!