Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

problem in configuring log4j in struts

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 ""
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???
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic