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

com.github.mtakaki.logentries.LogentriesAppenderFactory Maven / Gradle / Ivy

The newest version!
package com.github.mtakaki.logentries;

import java.util.TimeZone;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.logentries.logback.LogentriesAppender;

import io.dropwizard.logging.AbstractAppenderFactory;
import io.dropwizard.logging.AppenderFactory;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.Layout;
import lombok.Getter;
import lombok.Setter;

/**
 * An {@link AppenderFactory} implementation which provides an appender that
 * writes events to Logentries service. Configuration Parameters:
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
NameDefaultDescription
{@code threshold}{@code ALL}The lowest level of events to write to the file.
{@code token}REQUIREDThe account token used by logentries to determine the bucket where the * log will be stored.
{@code timeZone}{@code UTC}The time zone to which event timestamps will be converted.
{@code useDataHub}{@code false}Whether or not to use logentries data hub. If this is true, it will use * the next parameters.
{@code dataHubAddress}REQUIRED if {@code useDataHub} is {@code true}.The data hub address
{@code dataHubPort}REQUIRED if {@code useDataHub} is {@code true}.The port for the data hub host.
{@code location}The location information.
{@code logHostName}{@code false}Will determine if the host name should be logged or not.
{@code hostName}The host name.
{@code useSSL}{@code false}If it should SSL when pushing the logs.
{@code logId}The log id.
{@code httpPut}Will use HTTP PUT verb, instead of a POST.
* * @see AbstractAppenderFactory */ @JsonTypeName("logentries") @Getter @Setter public class LogentriesAppenderFactory extends AbstractAppenderFactory { private LogentriesAppender appender; @NotNull private String token; private boolean useSSL; @NotNull private TimeZone timeZone = TimeZone.getTimeZone("UTC"); // Datahub specific settings. private boolean useDataHub = false; private String dataHubAddress; private int dataHubPort; private String location; private boolean logHostName; private String hostName; private String logId; private boolean httpPut; @Override public Appender build(final LoggerContext context, final String applicationName, final Layout layout) { this.appender = new LogentriesAppender(); this.appender.setToken(this.token); this.appender.setSsl(this.useSSL); this.appender.setContext(context); this.appender.setName("logentries"); if (this.useDataHub) { this.appender.setIsUsingDataHub(this.useDataHub); this.appender.setDataHubAddr(this.dataHubAddress); this.appender.setDataHubPort(this.dataHubPort); this.appender.setLocation(this.location); this.appender.setLogHostName(this.logHostName); this.appender.setHostName(this.hostName); this.appender.setLogID(this.logId); this.appender.setHttpPut(this.httpPut); } this.appender.setLayout(layout == null ? this.buildLayout(context, this.timeZone) : layout); this.addThresholdFilter(this.appender, this.threshold); this.appender.start(); return this.wrapAsync(this.appender, context); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy