FileDocCategorySizeDatePackage
ExternallyRolledFileAppender.javaAPI DocApache log4j 1.2.154494Sat Aug 25 00:09:40 BST 2007org.apache.log4j.varia

ExternallyRolledFileAppender

public class ExternallyRolledFileAppender extends RollingFileAppender
This appender listens on a socket on the port specified by the Port property for a "RollOver" message. When such a message is received, the underlying log file is rolled over and an acknowledgment message is sent back to the process initiating the roll over.

This method of triggering roll over has the advantage of being operating system independent, fast and reliable.

A simple application {@link Roller} is provided to initiate the roll over.

Note that the initiator is not authenticated. Anyone can trigger a rollover. In production environments, it is recommended that you add some form of protection to prevent undesired rollovers.

author
Ceki Gülcü
since
version 0.9.0

Fields Summary
public static final String
ROLL_OVER
The string constant sent to initiate a roll over. Current value of this string constant is RollOver.
public static final String
OK
The string constant sent to acknowledge a roll over. Current value of this string constant is OK.
int
port
HUP
hup
Constructors Summary
public ExternallyRolledFileAppender()
The default constructor does nothing but calls its super-class constructor.


                      
  
   
  
Methods Summary
public voidactivateOptions()
Start listening on the port specified by a preceding call to {@link #setPort}.

    super.activateOptions();
    if(port != 0) {
      if(hup != null) {
	hup.interrupt();
      }
      hup = new HUP(this, port);
      hup.setDaemon(true);
      hup.start();
    }
  
public intgetPort()
Returns value of the Port option.

    return port;
  
public voidsetPort(int port)
The Port [roperty is used for setting the port for listening to external roll over messages.

    this.port = port;