logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Seetha Rama Krishna <ram_ku...@yahoo.co.in>
Subject log4j implementation for web module
Date Fri, 24 Nov 2006 07:15:44 GMT
Hi folks,
         I am very new log4j and i want to implement log4j in my module. I had gone through
material in net. 
          In my module i am having 5 to 6 servlets. For writting log4j code in web application,
we have to provide the properties file like this.

<servlet>
  <servlet-name>BackupServlet</servlet-name>
 <servlet-class>BackupServlet</servlet-class>
    <init-param>
          <param-name>props</param-name>
       <param-value>D:\www\tomcat5\webapps\ruleengine\WEB-INF\config.properties</param-value>
    </init-param>
  </servlet>

              And in each servlet init() method, we have to write the code like


String props = config.getInitParameter("props");
            if(props == null || props.length() == 0 ||
                    !(new File(props)).isFile()){

                    System.err.println(
                    "ERROR: Cannot read the configuration file. " +
                    "Please check the path of the config init param in web.xml");
                    throw new ServletException();
                }
            PropertyConfigurator.configure(props);
           log = Logger.getLogger(BackupServlet.class);


 I have few questions here,
1. how can i to write some genralized method, so that it can be used in any servlet class.

           i.e i dont want to write  "log = Logger.getLogger(BackupServlet.class);"
for each servlet.

  2.I am having so many classes in my module, for each class i cant write        Logger.getLogger(xxxx.class)
  .
                      Does any body knows please help me out.

 


          
   



  Thanks & Regards,
  Krishna
    

 				
---------------------------------
 Find out what India is talking about on  - Yahoo! Answers India 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message