io.dropwizard.logging.UdpSocketAppenderFactory Maven / Gradle / Ivy
package io.dropwizard.logging;
import ch.qos.logback.classic.LoggerContext;
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 io.dropwizard.logging.socket.DropwizardUdpSocketAppender;
import io.dropwizard.validation.PortRange;
import javax.validation.constraints.NotEmpty;
/**
* An {@link AppenderFactory} implementation which provides an appender that writes events to an UDP socket.
*
* Configuration Parameters:
*
*
* Name
* Default
* Description
*
*
* {@code host}
* {@code localhost}
* The hostname of the UDP server.
*
*
* {@code port}
* {@code 514}
* The port on which the UDP server is listening.
*
*
*/
@JsonTypeName("udp")
public class UdpSocketAppenderFactory extends AbstractOutputStreamAppenderFactory {
@NotEmpty
private String host = "localhost";
@PortRange
private int port = 514;
@JsonProperty
public String getHost() {
return host;
}
@JsonProperty
public void setHost(String host) {
this.host = host;
}
@JsonProperty
public int getPort() {
return port;
}
@JsonProperty
public void setPort(int port) {
this.port = port;
}
@Override
protected OutputStreamAppender appender(LoggerContext context) {
final DropwizardUdpSocketAppender appender = new DropwizardUdpSocketAppender<>(host, port);
appender.setContext(context);
appender.setName("udp-socket-appender");
return appender;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy