You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rex Madden <re...@microcreditcard.com> on 2001/01/26 04:52:08 UTC

NDC and RMI

Howdy all,

I have a web app that uses servlets, which in turn call some RMI business
objects.  I use the NDC class to store contextual information with the
servlets (I store IP address, session id, etc.) and would like to give that
information to the RMI objects.  But since the RMI objects are running in
their own thread, the only way I can think of to do it is to pass the
contextual data explicitly.  Obviously, it would be much better to get that
data to the RMI objects without having to add parameters to my function
calls.  I suspect that there’s not much I can do about it, but if anybody
has a better suggestion, I would appreciate it.

Thanks in advance,
Rex

RE: NDC and RMI

Posted by Rex Madden <re...@microcreditcard.com>.
Thanks Wes.  Yeah, those are pretty much the conclusions that I came to.
Basically, I’m starting to add contextInfo params to all of my RMI method
calls, passing the data using NDC.get(), and then pushing that data onto the
NDC once I get into the RMI method.  Not as transparent as I’d like it to
be, but it works.  I figure, at least if I’m consistent in naming the param,
it’ll be easy to identify and remove if I need to.

I just posted an inquiry to the java rmi mailing list, so hopefully they’ll
have a solution.  I’ll keep my fingers crossed.  At the very least, I’ll bet
we’ll get a few more log4j devotees.

Thanks again,
Rex

-----Original Message-----
From: Wes [mailto:wesyah234@yahoo.com]
Sent: Friday, January 26, 2001 11:06 AM
To: LOG4J Users Mailing List
Subject: Re: NDC and RMI

I'm also working with RMI, and I'm using 2 techniques to differentiate the
log messages inside an RMI server object.

1. I use the %t conversion pattern to print the current thread.  With RMI
services, I see something like RMI TCP Connection(1988)-172.30.50.133, and
the number between "()" is unique for each rmi connection.  This at least
tells me the ip of the client, and the unique number separates the
connections.  It doesn't, however, give you any link back to the actual
process on that machine.  (For that, I'd say you have to pass something into
your RMI service, which is 2.)

2. Some rmi method calls take a parameter that can uniquely tie back to a
particular client request.  I then use that parameter to set the NDC at the
start of the rmi method, and pop it off at the end of the method.

I also wish there was a way to tie the client to the server for logging
purposes without manually passing some identifier to the server...  I
suppose this would be a good question for an RMI users mailing list!

Wes
----- Original Message -----
From: Rex Madden <ma...@microcreditcard.com>
To: LOG4J Users Mailing List <ma...@jakarta.apache.org>
Sent: Thursday, January 25, 2001 9:52 PM
Subject: NDC and RMI

Howdy all,

I have a web app that uses servlets, which in turn call some RMI business
objects.  I use the NDC class to store contextual information with the
servlets (I store IP address, session id, etc.) and would like to give that
information to the RMI objects.  But since the RMI objects are running in
their own thread, the only way I can think of to do it is to pass the
contextual data explicitly.  Obviously, it would be much better to get that
data to the RMI objects without having to add parameters to my function
calls.  I suspect that there’s not much I can do about it, but if anybody
has a better suggestion, I would appreciate it.

Thanks in advance,
Rex

Re: NDC and RMI

Posted by Wes <we...@yahoo.com>.
Problem using BasicConfiguratorI'm also working with RMI, and I'm using 2 techniques to differentiate the log messages inside an RMI server object.

1. I use the %t conversion pattern to print the current thread.  With RMI services, I see something like RMI TCP Connection(1988)-172.30.50.133, and the number between "()" is unique for each rmi connection.  This at least tells me the ip of the client, and the unique number separates the connections.  It doesn't, however, give you any link back to the actual process on that machine.  (For that, I'd say you have to pass something into your RMI service, which is 2.)

2. Some rmi method calls take a parameter that can uniquely tie back to a particular client request.  I then use that parameter to set the NDC at the start of the rmi method, and pop it off at the end of the method.

I also wish there was a way to tie the client to the server for logging purposes without manually passing some identifier to the server...  I suppose this would be a good question for an RMI users mailing list!

Wes
  ----- Original Message ----- 
  From: Rex Madden 
  To: LOG4J Users Mailing List 
  Sent: Thursday, January 25, 2001 9:52 PM
  Subject: NDC and RMI


  Howdy all, 

   

  I have a web app that uses servlets, which in turn call some RMI business objects.  I use the NDC class to store contextual information with the servlets (I store IP address, session id, etc.) and would like to give that information to the RMI objects.  But since the RMI objects are running in their own thread, the only way I can think of to do it is to pass the contextual data explicitly.  Obviously, it would be much better to get that data to the RMI objects without having to add parameters to my function calls.  I suspect that there's not much I can do about it, but if anybody has a better suggestion, I would appreciate it.

   

  Thanks in advance,

  Rex