2 Replies Latest reply on Feb 20, 2004 12:05 AM by Mike Finn

    JMX client and Log4j

    gjb Newbie

      Hello. I have written a standalone java application that uses Log4j. I'm using the apache log4j, not the log4j that came with jboss.

      Next, I've added some functionality to this java application so that I can remotely connect to my JBoss server on which I've deployed several JMX MBeans. (I have a different client application that successfully connects with JMX, but it does not use log4j).

      After adding the JMX code, my log4j has stopped working. I think there is a conflict between log4j-1.2.8.jar and the jbossall-client.jar ??? I'm using jboss-3.2.1

      Here is the code in my java client application: (cut and paste relevent lines)

      import org.apache.log4j.*;
      import org.apache.log4j.xml.*;

      public Logger log = Logger.getLogger(getClass());

      log.info("hello log4j");
      System.out.println("should have seen log4j by now");

      This worked great!!! UNTIL I ADDED jbossclient-all.jar onto my classpath!!! then I no longer get any of my log4j logitems to my file or console!!!!!

      I need to add jbossclient-all.jar and jboss-jmx.jar onto my client application's classpath in order to do the following code to connect with my JMX MBEans on the remote server


      Hashtable env = new Hashtable();
      env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.provider.url", serverURL + ":1099");
      env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      InitialContext ctx = new InitialContext(env);
      RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/rmi/RMIAdaptor");

      ObjectName objName = new ObjectName("nokia.ans:service=Management");
      String method = "getFullList";
      Object[] params = { new Integer(dataType) };
      String[] signature = { "java.lang.Integer" };

      Object result = server.invoke(objName, method, params, signature);
      log.debug("result obj: " + result);

      resultList = (List)result;
      log.debug("resultList size: " + resultList.size());
      catch (Exception ex)
      log.error("EX: " + ex);


      Does anyone have any suggestions? Either I need to stop using the apache log4j and start using the log4j that jboss has extended..... or I need to find out how to continue using the original apache log4j AND add the necessary jboss client .jar files to use the naming lookup to jmx.

      Thanks, Gretel

        • 1. Re: JMX client and Log4j
          gjb Newbie

          It's not that log4j is no longer working, in fact my log file is being created, but no log items exist. I've discovered that it is only logging ERROR level, not below (whereas before it logged INFO, DEBUG, all levels). I've setup my log4j.xml with the Threshold of DEBUG, so I assumed everything would work as before I added jbossclient-all.jar to the classpath.

          I guess jbossclient-all.jar is somehow changing the log level from DEBUG to ERROR?

          Now I'll need to find how to programatically set the level back to DEBUG. Any tips?

          • 2. Re: JMX client and Log4j
            Mike Finn Apprentice

            There is a log4j.properties in jbossall-client.jar that may be getting in your way. In your app, try initializing do you force log4j config to load your log4j.xml?