4 Replies Latest reply on Aug 31, 2002 7:25 PM by mr_marcin

    How to log remote access

    ejain

      How does one log remote access to session beans (timestamp, bean, method, user, host)?

      Currently I have to look up the user from context.getCallerPrincipal().getName() each time I write a log statement (log4j), no idea how to determine the remote host. But surely there is a more elegant (and efficient) way to accomplish this basic task?

        • 1. Re: How to log remote access

          The log interceptor already does some
          basic call logging when enabled.

          http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jboss/src/main/org/jboss/ejb/plugins/LogInterceptor.java?rev=HEAD&content-type=text/vnd.viewcvs-markup

          You could always write your own interceptor to perform
          the logging required.

          Second question,
          java.rmi.server.RemoteServer.getClientHost()
          this assume all requests use JRMP.

          Regards,
          Adrian

          • 2. Re: How to log remote access
            mr_marcin

            hi, I have the same problem.

            I have added java.rmi.server.RemoteServer.getClientHost()
            call to LogInterceptor, and all seems to work fine, but only if I call EJB session bean method (I use logging for this purpose) from stand alone client. When I access the same bean from .jsp page I get error ServerNotActiveException.

            So in what way should I get ClientHost in that case.

            Thanks for any help.

            • 3. Re: How to log remote access

              The only way to do this across different protocols
              is to write a client interceptor (JBoss3 only).

              The client interceptor can retrieve the client host
              name (probably during static initialisation)
              and then add it to every invocation object sent.

              invocation.setValue("ClientHost", hostName);

              The server's log interceptor can then retrieve it.
              String client = (String) mi.getValue("ClientHost");

              Again, this will only work when the client is a java
              client. A c++ corba client cannot run the client
              interceptor.
              Also, this will show the server hostname when accessed
              through JSP.

              Regards,
              Adrian

              • 4. Re: How to log remote access
                mr_marcin

                Thank a lot, seens it could work from one side, from another its not as simple I thought it could be.
                I'll try to write that client interceptor, and hopes it will not tak much time and will work.

                Maybe somebody has another idea?

                Anyway thanks again,


                PS I'm sorry for posting this on two forums.