• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logging from the Data singleton

 
Paula Decker
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I created the Data class as a singleton. I have used java.util.logging.Logger to log exceptions from this class, but there is no way to identify the thread which is doing the logging. In the Data methods, IOExceptions are caught and changed to DatabaseExceptions. Before I change to DatabaseExceptions, I want to log the original exception. I am using RMI, so I don't have control of how the client threads are created.

How are others logging? From a singleton?

Thanks in advance.

-Paula
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Paula! Hope this is helpful:

 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paula Decker:
Hello,

I created the Data class as a singleton. I have used java.util.logging.Logger to log exceptions from this class, but there is no way to identify the thread which is doing the logging. In the Data methods, IOExceptions are caught and changed to DatabaseExceptions. Before I change to DatabaseExceptions, I want to log the original exception. I am using RMI, so I don't have control of how the client threads are created.

How are others logging? From a singleton?

Thanks in advance.

-Paula


I assign session numbers to the RMI connections. I use them as the locking cookies and to identify which connection is involved in logging messages. i even pass the session number over to the client so it can display it in the status message. All this makes it easy to tie client events to activities on the server.
 
Paula Decker
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anton and Peter,

I see I will have to add a connection object or method in the rmi server to generate an id for the user, and then use it in the logger.

I wonder if instead of adding more code, I could call getClientHost() in the RemoteServer which could be used to identify the user (or at least the user's machine). This probably isn't enough to truly identify the user or the user's session.

-Paula
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paula Decker:
Thanks Anton and Peter,

I see I will have to add a connection object or method in the rmi server to generate an id for the user, and then use it in the logger.

I wonder if instead of adding more code, I could call getClientHost() in the RemoteServer which could be used to identify the user (or at least the user's machine). This probably isn't enough to truly identify the user or the user's session.

-Paula


RMI may use multiple threads and multiple sockets over the life of a single connection. Thus you may not be able to use network attributes such as address and port to distinquish a client at the server. You will also need some sort of object that is shared by a single client for other purposes. I share an instance of Data per client across RMI using a DataAdapter and use a singleton to do the low level file access.
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by peter wooster:


RMI may use multiple threads and multiple sockets over the life of a single connection.


Peter,

Does this also mean that using the Thread's name as an identifier for a client is not correct? I am currently doing that in my server... (it seems to work)

Frans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic