4 Replies Latest reply on Mar 20, 2006 12:30 PM by Pragada Srikanth

    EJB Client log4j warnings

    Guillaume Bessez Newbie

      Hello,
      I developped my application with EJBs. Everything is OK, the deployment works fine etc...
      I then developped a client to test my application. It works OK but i get warnings at run time. My problem is that I want to display some information in the console from the client and it doesn't work. My warnings are linked to log4j.
      Any one can help me ?

      Warnings:
      log4j:WARN No appenders could be found for logger (myClient).
      log4j:WARN Please initialize the log4j system properly.

      My client:
      import org.apache.log4j.Logger;
      ...
      private static Logger log = Logger.getLogger(myClient.class);
      ...
      public myClient(String mss) {
      try {
      log.info("client " + mss);
      ...

      My config:
      Eclipse 3.1
      EJB3.0
      JBoss 4.0.3
      JBoss-EJB-3.0_RC3

        • 1. Re: EJB Client log4j warnings
          Darran Lofthouse Master

          1 - Do not cross post.

          2 - You need to read the log4j documentation and look at how to configure applications for logging.

          • 2. Re: EJB Client log4j warnings
            Pragada Srikanth Newbie

            I am experiencing the same problem. Can any one provide details regarding how to surpress the warning message.

            Thank you,
            Srikanth.

            • 3. Re: EJB Client log4j warnings
              Dasari Prasad Newbie

              use in the class of client

              import org.apache.log4j.*;


              in code

              static Logger logger;
              in main

              logger = Logger.getRootLogger();
              logger.addAppender(new FileAppender(new HTMLLocator(),
              "mylog1.log",true));

              ensure all log related jars are available(use ant)

              Prasad DTR

              • 4. Re: EJB Client log4j warnings
                Pragada Srikanth Newbie

                I solved the problem of Log4j warnings with the following code.


                import java.rmi.RemoteException;
                import java.util.Properties;
                import javax.naming.*;
                import javax.ejb.*;
                import javax.rmi.PortableRemoteObject;
                import org.apache.log4j.*;

                public class Client
                {
                private static final String JNDI_NAME = "st.hello";
                static Logger logger;
                public static void main(String[] args) throws Exception
                {

                logger = Logger.getRootLogger();
                logger.addAppender(new FileAppender( new HTMLLayout(), "log.html",true));


                Properties h = new Properties();
                h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                h.put(Context.PROVIDER_URL, "localhost:1099");
                h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
                Context ctx = new InitialContext(h);


                HelloHome home = (HelloHome ) ctx.lookup(JNDI_NAME);

                Hello hello = home.create();

                System.out.println(hello.sayHello("Srikanth"));

                }
                }

                It is writing the log into a HTML file called log.html.

                P.Srikanth.