Results 1 to 4 of 4
  1. #1
    arfatkhan is offline Member
    Join Date
    Jul 2007
    Posts
    9
    Rep Power
    0

    Default log4j initialization

    Hi Everybody,

    I want to use log4j in my application. I downloaded the required jar file, now I want to initialize it.Please help me, how to initialize log4j.

  2. #2
    mary is offline Member
    Join Date
    Jul 2007
    Posts
    51
    Rep Power
    0

    Default

    I give you an example
    Java Code:
    package com.foo;
    
    import org.apache.log4j.PropertyConfigurator;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.PrintWriter;
    import java.io.IOException;
    
    public class Log4jInit extends HttpServlet {
    
      public
      void init() {
        String prefix =  getServletContext().getRealPath("/");
        String file = getInitParameter("log4j-init-file");
        // if the log4j-init-file is not set, then no point in trying
        if(file != null) {
          PropertyConfigurator.configure(prefix+file);
        }
      }
    
      public
      void doGet(HttpServletRequest req, HttpServletResponse res) {
      }
    if you want more details you can check the documentation of the log4j project

  3. #3
    arfatkhan is offline Member
    Join Date
    Jul 2007
    Posts
    9
    Rep Power
    0

    Default

    Hi ,

    I am using weblogic server.As I mentioned I downloaded the required log4j.jar. When I am runing my application, on the server console I am getting this warning.

    log4j:WARN No appenders could be found for logger (org.apache.commons.digester.D
    igester).
    log4j:WARN Please initialize the log4j system properly.

    Please help me to overcome this problem.

    Thanks

  4. #4
    simon is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default

    This means that the log4j.properties file that you have created in NOT in
    the classpath. Make it available in the classpath.

Similar Threads

  1. Initialization and re-assignment of arrays
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:38 PM
  2. Replies: 0
    Last Post: 03-31-2008, 11:16 AM
  3. initialization value problem
    By ravian in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 11:54 AM
  4. Icon initialization problem
    By saz25 in forum AWT / Swing
    Replies: 1
    Last Post: 12-24-2007, 11:37 PM
  5. Lazy Initialization
    By onegcr in forum New To Java
    Replies: 1
    Last Post: 08-14-2007, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •