org.x4juli.handlers
Class ConsoleHandler

java.lang.Object
  extended byjava.util.logging.Handler
      extended byorg.x4juli.global.components.AbstractHandler
          extended byorg.x4juli.handlers.WriterHandler
              extended byorg.x4juli.handlers.ConsoleHandler
All Implemented Interfaces:
Component, ExtendedHandler, Handler, OptionHandler

public class ConsoleHandler
extends WriterHandler

ConsoleAppender appends log events to System.out or System.err using a layout specified by the user. The default target is System.out.

Attribute Description Required
.follow Sets whether the appender honors reassignments of System.out or System.err made after configuration. No. Default false.
.target Recognized values are "System.out" and "System.err". Any other value will be ignored. No. Default value is System.out

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Ceki Gülcü, Curt Arnold. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.6
Author:
Boris Unckel

Nested Class Summary
private static class ConsoleHandler.SystemErrStream
          An implementation of OutputStream that redirects to the current System.err.
private static class ConsoleHandler.SystemOutStream
          An implementation of OutputStream that redirects to the current System.out.
 
Field Summary
private  boolean follow
          Determines if the appender honors reassignments of System.out or System.err made after configuration.
static java.lang.String SYSTEM_ERR
           
static java.lang.String SYSTEM_OUT
           
protected  java.lang.String target
           
 
Fields inherited from class org.x4juli.handlers.WriterHandler
immediateFlush, writer
 
Fields inherited from class org.x4juli.global.components.AbstractHandler
active, closed, extFormatter, headFilter, manager, name, repository, tailFilter
 
Fields inherited from class java.util.logging.Handler
 
Constructor Summary
ConsoleHandler()
           
ConsoleHandler(java.lang.String handlerName)
           
 
Method Summary
 void activateOptions()
          Activate the options that were previously set with calls to option setters.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.
Subclasses have not set active to true, but call super as last statement!

protected  void closeWriter()
          Close the underlying Writer.
 void configure()
          Configure all properties of the object. Subclasses should call super.configure() to ensure proper configuration.
 boolean getFollow()
          Gets whether the appender honors reassignments of System.out or System.err made after configuration.
 java.lang.String getFullQualifiedClassName()
          Determine performant the FullQualifiedClassName. Subclasses should overwrite this method. Dynamic determination is not recommended.
 java.lang.String getTarget()
          Returns the current value of the Target property.
 void setFollow(boolean newValue)
          Sets whether the appender honors reassignments of System.out or System.err made after configuration.
 void setTarget(java.lang.String value)
          Sets the value of the Target option.
 
Methods inherited from class org.x4juli.handlers.WriterHandler
appendLogRecord, checkEntryConditions, close, createWriter, flush, getImmediateFlush, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader
 
Methods inherited from class org.x4juli.global.components.AbstractHandler
addFilter, clearFilters, finalize, getFilter, getFormatter, getLogger, getLoggerRepository, getMessageProperties, getName, getNonFloodingLogger, getProperty, getProperty, getProperty, isActive, isClosed, isLoggable, isLoggable, publish, publish, resetErrorCount, setFilter, setFormatter, setName, setObjectStore, toString
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getLevel, reportError, setEncoding, setErrorManager, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.x4juli.global.spi.ExtendedHandler
getEncoding, getErrorManager, getLevel, setEncoding, setErrorManager, setLevel
 

Field Detail

SYSTEM_OUT

public static final java.lang.String SYSTEM_OUT
See Also:
Constant Field Values

SYSTEM_ERR

public static final java.lang.String SYSTEM_ERR
See Also:
Constant Field Values

target

protected java.lang.String target

follow

private boolean follow
Determines if the appender honors reassignments of System.out or System.err made after configuration.

Constructor Detail

ConsoleHandler

public ConsoleHandler()

ConsoleHandler

public ConsoleHandler(java.lang.String handlerName)
Parameters:
handlerName -
Method Detail

configure

public void configure()
Configure all properties of the object. Subclasses should call super.configure() to ensure proper configuration.

Overrides:
configure in class WriterHandler
Since:
0.6

activateOptions

public void activateOptions()
Activate the options that were previously set with calls to option setters.

This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.
Subclasses have not set active to true, but call super as last statement!

Specified by:
activateOptions in interface OptionHandler
Overrides:
activateOptions in class WriterHandler
Since:
0.6

setTarget

public void setTarget(java.lang.String value)
Sets the value of the Target option. Recognized values are "System.out" and "System.err". Any other value will be ignored.

Since:
0.6

getTarget

public java.lang.String getTarget()
Returns the current value of the Target property. The default value of the option is "System.out". See also setTarget(java.lang.String).

Since:
0.6

setFollow

public final void setFollow(boolean newValue)
Sets whether the appender honors reassignments of System.out or System.err made after configuration.

Parameters:
newValue - if true, appender will use value of System.out or System.err in force at the time when logging events are appended.
Since:
0.6

getFollow

public final boolean getFollow()
Gets whether the appender honors reassignments of System.out or System.err made after configuration.

Returns:
true if appender will use value of System.out or System.err in force at the time when logging events are appended.
Since:
0.6

getFullQualifiedClassName

public java.lang.String getFullQualifiedClassName()
Determine performant the FullQualifiedClassName. Subclasses should overwrite this method. Dynamic determination is not recommended.

Specified by:
getFullQualifiedClassName in interface ExtendedHandler
Overrides:
getFullQualifiedClassName in class WriterHandler
Since:
0.6

closeWriter

protected final void closeWriter()
Close the underlying Writer.

Overrides:
closeWriter in class WriterHandler
Since:
0.6


${license_html}