public class ConsoleAppender extends WriterAppender
AppenderSkeleton.NoOpErrorHandler
Modifier and Type | Field and Description |
---|---|
static String |
SYSTEM_ERR |
static String |
SYSTEM_OUT |
protected String |
target |
encoding, immediateFlush, qw
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
Constructor and Description |
---|
ConsoleAppender()
Constructs a non-configured appender.
|
ConsoleAppender(Layout layout)
Constructs a configured appender.
|
ConsoleAppender(Layout layout,
String target)
Constructs a configured appender.
|
Modifier and Type | Method and Description |
---|---|
void |
append(LoggingEvent theEvent)
This method is called by the
AppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent)
method. |
void |
close()
Close this appender instance.
|
boolean |
getFollow()
Gets whether the appender honors reassignments of System.out or System.err made after configuration.
|
String |
getTarget()
Gets the current value of the Target property.
|
boolean |
requiresLayout()
The WriterAppender requires a layout.
|
void |
setFollow(boolean follow)
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.
|
activateOptions, checkEntryConditions, closeWriter, createWriter, getEncoding, getImmediateFlush, reset, setEncoding, setErrorHandler, setImmediateFlush, setWriter, shouldFlush, subAppend, writeFooter, writeHeader
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold
public static final String SYSTEM_OUT
public static final String SYSTEM_ERR
protected String target
public ConsoleAppender()
public ConsoleAppender(Layout layout)
layout
- layout, may not be null.public void append(LoggingEvent theEvent)
AppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent)
method.
If the output stream exists and is writable then write a log
statement to the output stream. Otherwise, write a single warning
message to System.err
.
The format of the output will depend on this appender's layout.
append
in class WriterAppender
public void close()
Closed appenders cannot be reused.
close
in interface Appender
close
in class WriterAppender
WriterAppender.setWriter(java.io.Writer)
public boolean getFollow()
public String getTarget()
setTarget(java.lang.String)
.public boolean requiresLayout()
true
.requiresLayout
in interface Appender
requiresLayout
in class WriterAppender
public void setFollow(boolean follow)
follow
- 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)
Copyright © 1999-2024 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.