public class

ConsoleAppender

extends WriterAppender
java.lang.Object
   ↳ org.apache.log4j.AppenderSkeleton
     ↳ org.apache.log4j.WriterAppender
       ↳ org.apache.log4j.ConsoleAppender

Class Overview

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

Summary

Constants
String SYSTEM_ERR
String SYSTEM_OUT
Fields
protected String target
[Expand]
Inherited Fields
From class org.apache.log4j.WriterAppender
From class org.apache.log4j.AppenderSkeleton
Public Constructors
ConsoleAppender()
Constructs an unconfigured appender.
ConsoleAppender(Layout layout)
Creates a configured appender.
ConsoleAppender(Layout layout, String target)
Creates a configured appender.
Public Methods
void activateOptions()
Prepares the appender for use.
final boolean getFollow()
Gets whether the appender honors reassignments of System.out or System.err made after configuration.
String getTarget()
Returns the current value of the Target property.
final void setFollow(boolean newValue)
Sets whether the appender honors reassignments of System.out or System.err made after configuration.
void setTarget(String value)
Sets the value of the Target option.
Protected Methods
final void closeWriter()
Close the underlying java.io.Writer.
[Expand]
Inherited Methods
From class org.apache.log4j.WriterAppender
From class org.apache.log4j.AppenderSkeleton
From class java.lang.Object
From interface org.apache.log4j.Appender
From interface org.apache.log4j.spi.OptionHandler

Constants

public static final String SYSTEM_ERR

Constant Value: "System.err"

public static final String SYSTEM_OUT

Constant Value: "System.out"

Fields

protected String target

Public Constructors

public ConsoleAppender ()

Constructs an unconfigured appender.

public ConsoleAppender (Layout layout)

Creates a configured appender.

Parameters
layout layout, may not be null.

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".

Public Methods

public void activateOptions ()

Prepares the appender for use.

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.

public String getTarget ()

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

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.

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.

Protected Methods

protected final void closeWriter ()

Close the underlying java.io.Writer.