Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.java.io
Class LogWriter

    java.lang.Object
      |
      +--org.apache.java.io.LogWriter

public class LogWriter
extends java.lang.Object
implements Logger

A `LogWriter` allows an application to incapsulate an output stream and dumps its logs on it.

To control the different kinds of log messages they are separated into channels that can be activated setting to true the right property.

The configurations that control this writer are:

- "identifier" a boolean value that enables the whole logging
- "identifier".dateFormat the date format used to time stamp
- "identifier".timestamp a boolean value that enables time stamping
- "identifier".channel."channelName" a boolean value that enables the specified channel

  Version:
    $Revision: 1.27 $ $Date: 1999/11/09 21:57:40 $

  Inner Class Summary
  `protected class` | `LogWriter.Agent` Class implementing the background logging.

  Field Summary
  `boolean` | `active` Tells if this log is active
  `static java.lang.String` | `CH_EXCEPTION_TRACING` String identifier for the exception tracing channel.
  `static java.lang.String` | `CH_QUEUE_STATUS`
  `Configurations` | `configurations` Configuration parameters.
  `static java.lang.String` | `DEFAULT_DATEFORMAT` This string control the standard date format used used for log timestamping.
  `static java.lang.String` | `DEFAULT_IDENTIFIER` This string identifies this log writer and its used to differentiate between configurations.
  `private java.text.SimpleDateFormat` | `formatter` The timestamp formatter.
  `private java.lang.String` | `identifier` This string identifies this log writer and its used to discriminate between configuration parameters.
  `static java.lang.String` | `KEYWORD_CHANNEL`
  `static java.lang.String` | `KEYWORD_DATEFORMAT`
  `static java.lang.String` | `KEYWORD_FILE`
  `static java.lang.String` | `KEYWORD_QUEUE_MAXAGE`
  `static java.lang.String` | `KEYWORD_QUEUE_MAXSIZE`
  `static java.lang.String` | `KEYWORD_TIMESTAMP`
  `private boolean` | `logChannel` Tells if the log message should contain a channel.
  `private LogWriter.Agent` | `logDaemon` Background logger thread.
  `protected SimpleQueue` | `logQueue` Log message queue.
  `private long` | `queue_maxage` Maximum age of a queued log record, in milliseconds.
  `private long` | `queue_maxsize` Maximum size of a log queue.
  `private boolean` | `timestamp` Tells if the log message should be started by a time stamp.
  `private java.io.PrintWriter` | `writer` The writer encapsulated.

  Constructor Summary
  `LogWriter(Configurations configurations)` Constructs this class and gets output file from configurations.
  `LogWriter(java.io.OutputStream output, Configurations configurations)` Constructs this class with the output stream to encapsulate using default identifier.
  `LogWriter(java.io.OutputStream output, java.lang.String identifier, Configurations configurations)` Constructs this class with the output stream to encapsulate.
  `LogWriter(java.lang.String identifier, Configurations configurations)` Constructs this class using identifier to discriminate between configuration parameters and gets output file from configurations.
  `LogWriter(java.io.Writer output, Configurations configurations)` Constructs this class with the output writer to encapsulate using default identifier.
  `LogWriter(java.io.Writer output, java.lang.String identifier, Configurations configurations)` Constructs this class with the output writer to encapsulate.

  Method Summary
  `void` | `flush()` Flush the log.
  `boolean` | `isActive()` Tells if it is active.
  `boolean` | `isActive(java.lang.String channel)` Tells if the given channel is active.
  `void` | `log(java.lang.String channel, java.lang.String message)` Prints the log message on the right channel.
  `void` | `log(java.lang.String channel, java.lang.Throwable t)` Prints the error message and stack trace if channel enabled.
  `void` | `log(java.lang.Throwable t)` Deprecated.

  Methods inherited from class java.lang.Object
  `, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait`

  Field Detail

  ### DEFAULT_IDENTIFIER

      public static final java.lang.String DEFAULT_IDENTIFIER

    This string identifies this log writer and its used to differentiate between configurations.

  ### DEFAULT_DATEFORMAT

      public static final java.lang.String DEFAULT_DATEFORMAT

    This string control the standard date format used used for log timestamping.

  ### KEYWORD_DATEFORMAT

      public static final java.lang.String KEYWORD_DATEFORMAT

  ### KEYWORD_TIMESTAMP

      public static final java.lang.String KEYWORD_TIMESTAMP

  ### KEYWORD_CHANNEL

      public static final java.lang.String KEYWORD_CHANNEL

  ### KEYWORD_FILE

      public static final java.lang.String KEYWORD_FILE

  ### KEYWORD_QUEUE_MAXAGE

      public static final java.lang.String KEYWORD_QUEUE_MAXAGE

  ### KEYWORD_QUEUE_MAXSIZE

      public static final java.lang.String KEYWORD_QUEUE_MAXSIZE

  ### CH_QUEUE_STATUS

      public static final java.lang.String CH_QUEUE_STATUS

  ### CH_EXCEPTION_TRACING

      public static final java.lang.String CH_EXCEPTION_TRACING

    String identifier for the exception tracing channel.

  ### configurations

      public Configurations configurations

    Configuration parameters.

  ### active

      public boolean active

    Tells if this log is active

  ### queue_maxage

      private long queue_maxage

    Maximum age of a queued log record, in milliseconds.

    When the log daemon detects the record older than this, it flushes the queue, just to make the observer happy, even if that is a single message in the queue.

    Default is hardcoded to 5000 ms.

  ### queue_maxsize

      private long queue_maxsize

    Maximum size of a log queue.

    When one of the `log(...)` messages detects that the log queue size is more than this variable permits, it flushes the queue, to keep the memory clean.

    Default is 1000.

  ### identifier

      private java.lang.String identifier

    This string identifies this log writer and its used to discriminate between configuration parameters.

  ### timestamp

      private boolean timestamp

    Tells if the log message should be started by a time stamp. Default is false.

  ### formatter

      private java.text.SimpleDateFormat formatter

    The timestamp formatter.

  ### writer

      private java.io.PrintWriter writer

    The writer encapsulated.

  ### logDaemon

      private LogWriter.Agent logDaemon

    Background logger thread.

  ### logChannel

      private boolean logChannel

    Tells if the log message should contain a channel. Default is false.

  ### logQueue

      protected SimpleQueue logQueue

    Log message queue. Supposed to keep the messages until they get processed by the background logger thread.

  Constructor Detail

  ### LogWriter

      public LogWriter(Configurations configurations)
                throws java.io.IOException

    Constructs this class and gets output file from configurations.
    Parameters:
      `configurations` - the configurations needed at initialization.

  ### LogWriter

      public LogWriter(java.lang.String identifier,
                       Configurations configurations)
                throws java.io.IOException

    Constructs this class using identifier to discriminate between configuration parameters and gets output file from configurations.
    Parameters:
      `identifier` - the identifier for this log writer.
      `configurations` - the configurations needed at initialization.

  ### LogWriter

      public LogWriter(java.io.Writer output,
                       Configurations configurations)
                throws java.io.IOException

    Constructs this class with the output writer to encapsulate using default identifier.
    Parameters:
      `output` - the output writer to encapsulate.
      `configurations` - the configurations needed at initialization.

  ### LogWriter

      public LogWriter(java.io.OutputStream output,
                       Configurations configurations)
                throws java.io.IOException

    Constructs this class with the output stream to encapsulate using default identifier.
    Parameters:
      `output` - the output stream to encapsulate.
      `configurations` - the configurations needed at initialization.

  ### LogWriter

      public LogWriter(java.io.OutputStream output,
                       java.lang.String identifier,
                       Configurations configurations)
                throws java.io.IOException

    Constructs this class with the output stream to encapsulate. The log identifier is used to discriminate between configuration parameters.
    Parameters:
      `output` - the output stream to encapsulate.
      `identifier` - the identifier for this log writer.
      `configurations` - the configurations needed at initialization.

  ### LogWriter

      public LogWriter(java.io.Writer output,
                       java.lang.String identifier,
                       Configurations configurations)
                throws java.io.IOException

    Constructs this class with the output writer to encapsulate. The log identifier is used to discriminate between configuration parameters.
    Parameters:
      `output` - the output writer to encapsulate.
      `identifier` - the identifier for this log writer.
      `configurations` - the configurations needed at initialization.

  Method Detail

  ### isActive

      public boolean isActive()

    Tells if it is active.
    Specified by:
      isActive in interface Logger

  ### isActive

      public boolean isActive(java.lang.String channel)

    Tells if the given channel is active.
    Specified by:
      isActive in interface Logger
    Parameters:
      `channel` - the channel to test.

  ### log

      public void log(java.lang.String channel,
                      java.lang.String message)

    Prints the log message on the right channel.

    A "channel" is a virtual log that may be enabled or disabled by setting the property "identifier".channel.???=true where ??? is the channel identifier that must be passed with the message. If a channel is not recognized or its property is set to false the message is not written.

    Specified by:
      log in interface Logger
    Parameters:
      `channel` - the channel to put the message on.
      `name` - the message to log.

  ### log

      public void log(java.lang.String channel,
                      java.lang.Throwable t)

    Prints the error message and stack trace if channel enabled.
    Specified by:
      log in interface Logger
    Parameters:
      `t` - the error thrown.

  ### log

      public void log(java.lang.Throwable t)

    Deprecated.

  ### flush

      public void flush()

    Flush the log. Write any pending messages into the log media.
    Specified by:
      flush in interface Logger

  Overview | Package | Class | Tree | Deprecated | Index | Help
  PREV CLASS NEXT CLASS | FRAMES NO FRAMES
  SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD