Package org.apache.log4j
Class ConsoleAppender
- java.lang.Object
-
- org.apache.log4j.AppenderSkeleton
-
- org.apache.log4j.WriterAppender
-
- org.apache.log4j.ConsoleAppender
-
- All Implemented Interfaces:
org.apache.log4j.Appender
,org.apache.log4j.spi.OptionHandler
public class ConsoleAppender extends org.apache.log4j.WriterAppender
ConsoleAppender appends log events toSystem.out
orSystem.err
using a layout specified by the user. The default target isSystem.out
.Modification was done in JBoss fork to use the real stdout/stderr via
FileDescriptor.out
/FileDescriptor.err
instead ofSystem.out
/System.err
, because in some cases, the standard stream may be reassigned.- Since:
- 1.1
- Author:
- Ceki Gülcü, Curt Arnold, Lin Gao
-
-
Field Summary
Fields Modifier and Type Field Description static String
SYSTEM_ERR
static String
SYSTEM_OUT
protected String
target
-
Constructor Summary
Constructors Constructor Description ConsoleAppender()
Constructs an unconfigured appender.ConsoleAppender(org.apache.log4j.Layout layout)
Creates a configured appender.ConsoleAppender(org.apache.log4j.Layout layout, String target)
Creates a configured appender.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateOptions()
Prepares the appender for use.protected void
closeWriter()
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.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.-
Methods inherited from class org.apache.log4j.WriterAppender
append, checkEntryConditions, close, createWriter, getEncoding, getImmediateFlush, requiresLayout, reset, setEncoding, setErrorHandler, setImmediateFlush, setWriter, shouldFlush, subAppend, writeFooter, writeHeader
-
-
-
-
Field Detail
-
SYSTEM_OUT
public static final String SYSTEM_OUT
- See Also:
- Constant Field Values
-
SYSTEM_ERR
public static final String SYSTEM_ERR
- See Also:
- Constant Field Values
-
target
protected String target
-
-
Constructor Detail
-
ConsoleAppender
public ConsoleAppender()
Constructs an unconfigured appender.
-
ConsoleAppender
public ConsoleAppender(org.apache.log4j.Layout layout)
Creates a configured appender.- Parameters:
layout
- layout, may not be null.
-
ConsoleAppender
public ConsoleAppender(org.apache.log4j.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
-
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.
-
getTarget
public String getTarget()
Returns the current value of the Target property. The default value of the option is "System.out". See alsosetTarget(java.lang.String)
.
-
setFollow
public final void setFollow(boolean newValue)
Sets whether the appender honors reassignments of System.out or System.err made after configuration.Note: The follow value is not used and streams will always be closed and recreated if necessary.
- 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
-
getFollow
public final boolean getFollow()
Gets whether the appender honors reassignments of System.out or System.err made after configuration.Note: The follow value is not used and streams will always be closed and recreated if necessary.
- 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
-
activateOptions
public void activateOptions()
Prepares the appender for use.- Specified by:
activateOptions
in interfaceorg.apache.log4j.spi.OptionHandler
- Overrides:
activateOptions
in classorg.apache.log4j.WriterAppender
-
closeWriter
protected final void closeWriter()
- Overrides:
closeWriter
in classorg.apache.log4j.WriterAppender
-
-