Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Logging - Cryptic output

 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, this might very well be a "Duh" question but I've noticed that when I run my RMI servers, a "log" directory is made with the following files:
Logfile.1
Snapshot.1
Version_Number
Does anyone know what those files are? I would think that they contain RMI logging output but none of the files are in a readable text format.
I need to turn on much of the RMI logging facilities to debug a problem and I'm trying to figure out where and how to read the log files. Any help would be appreciated.
I've never worked with 1.4's logging mechanism before. I use log4j.
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I found this information: http://user-aecolley.jini.org/#rmi which seems to answer my above questions in regards to the "log" directory.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for posting your solution. It might help someone else who is having the same problem.
Chris
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A followup on what I've found out for turning on the default RMI logging:
1) Refer to RMI Implementation Logging for the list of RMI logging properties.
2) Pass "-C-Djava.rmi.server.logCalls=true" when you run the rmid program. You might also want to pass "-C-Dsun.rmi.log.debug=true" as well.
An example command looks like:
${JAVA_HOME}/bin/rmid -J-Djava.security.policy=mypolicy.file -C-Djava.rmi.server.logCalls=true -C-Dsun.rmi.log.debug=true &
* Note: This caused the RMI logging output to be printed via System.err on my console window which wasn't very helpful since I wanted it saved to a file. In my search I came across these 2 tidbits in a couple of RMI books:
The easiest way to get the "sun.rmi.*" logs to be saved to a log file is to redirect System.err

You have to set the logging destination before you invoke any RMI methods. Once RMI starts loggging to a particular PrintSteam, it keeps logging to that PrintStream.

Check this link for code on how to redirect to System.err: Redirecting streams
The conclusion:
The code that redirects System.err is run only when a remote method is called, mainly because I'm using Activatable objects (the implementation classes reference a constants class which has a static code block that has the redirection code). Because of that, I can't satisfy the condition stated in the second quote which means I still don't know how to get the RMI logging to be output to a file.
At the very least, I can at least see the RMI log output now.
Hope this helps anyone else.
[ February 18, 2004: Message edited by: David Duran ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic