org.log5j
Class Writer

java.lang.Object
  extended by org.log5j.Writer
Direct Known Subclasses:
ConsoleWriter, FileWriter, RollingFileWriter, SocketWriter

public abstract class Writer
extends java.lang.Object

Extend this abstract class to create a new writer for log messages.

Any number of writers can be specified in Log5j configuration for any given Logger.

To set the Writer for a particular Logger set a property with a name of <logger-name>.writer.<writer-name> and a value which is the fully qualified class name of the Writer.

All concrete classes that extend Writer must have a constructor that takes a Format object and a Properties object as arguments. For example;

 public class MyWriter extends Writer {
 
     public MyWriter(Format format, Properties properties) {
 
     }
 
     ...
 }
 
It must also, of course, implement the write(String) method which writes the message to it's destination. This method must be thread-safe.

Many Writer classes have their own configuration properties. These are documented fully in the javadocs for those classes.

Author:
Bruce Ashton

Constructor Summary
protected Writer(Format format)
          Any class that extends AbstractWriter must call this constructor and provide suitable values for format.
 
Method Summary
 Format getFormat(Format defaultFormat)
          Return the log format object for this writer or defaultFormat if this writer has no specific format.
abstract  void write(java.lang.String message)
          Write a single message to the log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Writer

protected Writer(Format format)
Any class that extends AbstractWriter must call this constructor and provide suitable values for format. format can be null, in which case the argument defaultFormat will always be returned by getFormat(Format).

Parameters:
format - the Format object for this Writer
Method Detail

getFormat

public final Format getFormat(Format defaultFormat)
Return the log format object for this writer or defaultFormat if this writer has no specific format.

Parameters:
defaultFormat - a Format object
Returns:
a Format object

write

public abstract void write(java.lang.String message)
Write a single message to the log.

Parameters:
message - the message to write