Log4j 1.1.3

org.apache.log4j.examples
Class NumberCruncherServer

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--org.apache.log4j.examples.NumberCruncherServer
All Implemented Interfaces:
NumberCruncher, Remote, Serializable

public class NumberCruncherServer
extends UnicastRemoteObject
implements NumberCruncher

A simple NumberCruncher implementation that logs its progress when factoring numbers. The purpose of the whole exercise is to show the use of nested diagnostic contexts in order to distinguish the log output from different client requests.

Usage: java org.apache.log4j.examples.NumberCruncherServer configFile
      where configFile is a log4j configuration file.
We supply a simple config file factor.lcf for directing log output to the file factor.log.

Try it yourself by starting a NumberCruncherServer and make queries from multiple NumberCruncherClients to factor numbers.

Sample output shows the log output when two clients connect to the server near simultaneously.

See source code of NumberCruncherServer for more details.

Note that class files for the example code is not included in any of the distributed log4j jar files. You will have to add the directory /dir-where-you-unpacked-log4j/classes to your classpath before trying out the examples.

See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
NumberCruncherServer()
           
 
Method Summary
static void delay(int millis)
           
 int[] factor(int number)
          Factor a positive integer number and return its distinct factor's as an integer array.
static void main(String[] args)
           
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberCruncherServer

public NumberCruncherServer()
                     throws RemoteException
Method Detail

factor

public int[] factor(int number)
             throws RemoteException
Description copied from interface: NumberCruncher
Factor a positive integer number and return its distinct factor's as an integer array.
Specified by:
factor in interface NumberCruncher

delay

public static void delay(int millis)

main

public static void main(String[] args)

Log4j 1.1.3

Please notify me about new log4j releases.