org.apache.log4j

Class ConsoleAppender

public class ConsoleAppender extends WriterAppender

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

Since: 1.1

Author: Ceki Gülcü Curt Arnold

Field Summary
static StringSYSTEM_ERR
static StringSYSTEM_OUT
protected Stringtarget
Constructor Summary
ConsoleAppender()
Constructs an unconfigured appender.
ConsoleAppender(Layout layout)
Creates a configured appender.
ConsoleAppender(Layout layout, String target)
Creates a configured appender.
Method Summary
voidactivateOptions()
Prepares the appender for use.
protected voidcloseWriter()
{@inheritDoc}
booleangetFollow()
Gets whether the appender honors reassignments of System.out or System.err made after configuration.
StringgetTarget()
Returns the current value of the Target property.
voidsetFollow(boolean newValue)
Sets whether the appender honors reassignments of System.out or System.err made after configuration.
voidsetTarget(String value)
Sets the value of the Target option.

Field Detail

SYSTEM_ERR

public static final String SYSTEM_ERR

SYSTEM_OUT

public static final String SYSTEM_OUT

target

protected String target

Constructor Detail

ConsoleAppender

public ConsoleAppender()
Constructs an unconfigured appender.

ConsoleAppender

public ConsoleAppender(Layout layout)
Creates a configured appender.

Parameters: layout layout, may not be null.

ConsoleAppender

public ConsoleAppender(Layout layout, String target)
Creates a configured appender.

Parameters: layout layout, may not be null. target target, either "System.err" or "System.out".

Method Detail

activateOptions

public void activateOptions()
Prepares the appender for use.

closeWriter

protected final void closeWriter()
{@inheritDoc}

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: 1.2.13

getTarget

public String getTarget()
Returns the current value of the Target property. The default value of the option is "System.out". See also {@link #setTarget}.

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: 1.2.13

setTarget

public void setTarget(String value)
Sets the value of the Target option. Recognized values are "System.out" and "System.err". Any other value will be ignored.
Copyright 2000-2005 Apache Software Foundation.