1 Reply Latest reply on Feb 26, 2003 1:24 PM by Mikael Eriksson

    CMP 2.0 Log4J NDC

    Jeffrey Inns Newbie

      I am experiancing some bizarre behaviour with Log4J and the NDC and (I think) the CMP 2.0 implementation.

      We use the NDC heavily in our application as does JBoss(from what I've seen).

      I have a session bean that invokes a setter on a certain CMP 2.0 entity bean. Before I invoke the setter I set the NDC to a given value. After I invoke the setter, the NDC is null(which means the NDC.remove() or NDC.clear() methods have been called down in the bowels of the container.

      If someone could look into this for me, I'd greatly appreciate it.


        • 1. Re: CMP 2.0 Log4J NDC
          Mikael Eriksson Novice

          This happened to me too, and I did some checking.

          It seems that everywhere that JBoss code does
          a NDC.push()/pop() it also does a NDC.remove().

          This feels like a bug and that the NDC.remove() only
          should be called when the thread itself is removed.
          (Have not gotten around to file a report about it though)

          To get around this I used the log4j.MDC instead and
          updated the config file to display a MDC.

          Ex: log4.xml %X{user} is the MDC

          Then I do a
          MDC.put("user", userInfo);
          at the start of every request in the web layer.
          (userinfo is username + remote ip addr btw)

          I have not tested this under load yet, but so far the same thread seems to be used all the way down to the EJB layer.