org.apache.logging.log4j.core.appender
Class ConsoleAppender

java.lang.Object
  extended by org.apache.logging.log4j.core.filter.AbstractFilterable
      extended by org.apache.logging.log4j.core.appender.AbstractAppender
          extended by org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
              extended by org.apache.logging.log4j.core.appender.ConsoleAppender
All Implemented Interfaces:
Appender, Filterable, LifeCycle

public final class ConsoleAppender
extends AbstractOutputStreamAppender

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

Troublesome:
accessing System.out or .err as a byte stream instead of a writer bypasses the JVM's knowledge of the proper encoding. (RG) Encoding is handled within the Layout. Typically, a Layout will generate a String and then call getBytes which may use a configured encoding or the system default. OTOH, a Writer cannot print byte streams.

Nested Class Summary
static class ConsoleAppender.Target
          Enumeration of console destinations.
 
Field Summary
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
immediateFlush
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
LOGGER
 
Method Summary
static ConsoleAppender createAppender(Layout layout, Filter filter, String t, String name, String follow, String suppress)
          Create a Console Appender.
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
append, getManager, replaceManager, start, stop
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
close, error, error, error, getHandler, getLayout, getName, isExceptionSuppressed, isStarted, setHandler, toString
 
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, hasFilter, isFiltered, removeFilter, startFilter, stopFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

createAppender

public static ConsoleAppender createAppender(Layout layout,
                                             Filter filter,
                                             String t,
                                             String name,
                                             String follow,
                                             String suppress)
Create a Console Appender.

Parameters:
layout - The layout to use (required).
filter - The Filter or null.
t - The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
follow - If true will follow changes to the underlying output stream.
name - The name of the Appender (required).
suppress - "true" if exceptions should be hidden from the application, "false" otherwise. The default is "true".
Returns:
The ConsoleAppender.


Copyright © 1999-2013 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.