Class ConsoleAppender

  • All Implemented Interfaces:
    Appender, Filterable, LocationAware, LifeCycle, LifeCycle2

    @Plugin(name="Console",
            category="Core",
            elementType="appender",
            printObject=true)
    public final class ConsoleAppender
    extends AbstractOutputStreamAppender<OutputStreamManager>
    Appends log events to System.out or System.err using a layout specified by the user. The default target is System.out.

    TODO Accessing System.out or System.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.

    • Method Detail

      • createAppender

        @Deprecated
        public static ConsoleAppender createAppender​(Layout<? extends Serializable> layout,
                                                     Filter filter,
                                                     String targetStr,
                                                     String name,
                                                     String follow,
                                                     String ignore)
        Deprecated.
        Deprecated in 2.7; use newBuilder().
        Creates a Console Appender.
        Parameters:
        layout - The layout to use (required).
        filter - The Filter or null.
        targetStr - The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
        name - The name of the Appender (required).
        follow - If true will follow changes to the underlying output stream.
        ignore - If "true" (default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.
        Returns:
        The ConsoleAppender.
      • createAppender

        @Deprecated
        public static ConsoleAppender createAppender​(Layout<? extends Serializable> layout,
                                                     Filter filter,
                                                     ConsoleAppender.Target target,
                                                     String name,
                                                     boolean follow,
                                                     boolean direct,
                                                     boolean ignoreExceptions)
        Deprecated.
        Deprecated in 2.7; use newBuilder().
        Creates a Console Appender.
        Parameters:
        layout - The layout to use (required).
        filter - The Filter or null.
        target - The target (SYSTEM_OUT or SYSTEM_ERR). The default is SYSTEM_OUT.
        name - The name of the Appender (required).
        follow - If true will follow changes to the underlying output stream.
        direct - If true will write directly to FileDescriptor and bypass System.out/System.err.
        ignoreExceptions - If "true" (default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.
        Returns:
        The ConsoleAppender.