O'Reilly logo

Java RMI by William Grosso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

RMI’s Logging Facilities

In addition to a distributed garbage collector, the RMI runtime also provides a fairly extensive logging facility that enables you to track the behavior of your applications. Unfortunately, RMI’s logging is somewhat idiosyncratic. There are actually three different types of logs: the standard log, the specialized logs (there are five of these), and the debugging log.

The Standard Log

The standard log is easy to use. You turn it on and off using the java.rmi.server.logCalls system property. This is a boolean system property. Note that this property can either be set at the command line or in code. There is no functional difference between the command line invocation:

java -Djava.rmi.server.logCalls=true [other stuff]

and using:

java [same other stuff]

to invoke a program that contains the line:

System.getProperties(  ).put("java.rmi.server.logCalls", "true");

Warning

Actually, this isn’t quite true. At the command line, you always have permission to set system properties. Depending on your security policy, a program might not have permission to do so. We’ll explore this more in Chapter 20.

Once you’ve turned logging on, you need to set the logging destination. This is done by using one of the static logging methods defined in the RemoteServer class, which is defined in the java.rmi.server package. The methods are:

public static PrintStream getLog(  ) 
public static void setLog(OutputStream out)

The first retrieves the stream currently used to do logging, and the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required