All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.logging.ConsoleAppenderFactory Maven / Gradle / Ivy

There is a newer version: 5.0.0-alpha.5
Show newest version
package io.dropwizard.logging;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.OutputStreamAppender;
import ch.qos.logback.core.spi.DeferredProcessingAware;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

import javax.validation.constraints.NotNull;

/**
 * An {@link AppenderFactory} implementation which provides an appender that writes events to the console.
 * 

* Configuration Parameters: *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
NameDefaultDescription
{@code type}REQUIREDThe appender type. Must be {@code console}.
{@code threshold}{@code ALL}The lowest level of events to print to the console.
{@code timeZone}{@code UTC}The time zone to which event timestamps will be converted.
{@code target}{@code stdout} * The name of the standard stream to which events will be written. * Can be {@code stdout} or {@code stderr}. *
{@code logFormat}the default format * The Logback pattern with which events will be formatted. See * the Logback documentation * for details. *
* * @see AbstractAppenderFactory */ @JsonTypeName("console") public class ConsoleAppenderFactory extends AbstractOutputStreamAppenderFactory { @SuppressWarnings("UnusedDeclaration") public enum ConsoleStream { STDOUT("System.out"), STDERR("System.err"); private final String value; ConsoleStream(String value) { this.value = value; } public String get() { return value; } } @NotNull private ConsoleStream target = ConsoleStream.STDOUT; @JsonProperty public ConsoleStream getTarget() { return target; } @JsonProperty public void setTarget(ConsoleStream target) { this.target = target; } @Override protected OutputStreamAppender appender(LoggerContext context) { final ConsoleAppender appender = new ConsoleAppender<>(); appender.setName("console-appender"); appender.setContext(context); appender.setTarget(target.get()); return appender; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy