.setConfiguration(ctx.getConfiguration()) .setHost(host) .setAdditionalFields(new KeyValuePair[] { new KeyValuePair(KEY1, VALUE1), new KeyValuePair(KEY2, "${java:runtime}"), }) .setCompressionType(compressionType) .setCompressionThreshold(1024) .setIncludeStacktrace(includeStacktrace) .setIncludeThreadContext(includeThreadContext) .setIncludeNullDelimiter(includeNullDelimiter) .build(); final ListAppender eventAppender = new ListAppender("Events", null, null, true, false); final ListAppender rawAppender = new ListAppender("Raw", null, layout, true, true);
public Builder() { super(); setCharset(StandardCharsets.UTF_8); }
/** * Whether to include full stacktrace of logged Throwables (optional, default to true). * If set to false, only the class name and message of the Throwable will be included. * * @return this builder */ public B setIncludeStacktrace(final boolean includeStacktrace) { this.includeStacktrace = includeStacktrace; return asBuilder(); }
/** * Compression to use (optional, defaults to GZIP). * * @return this builder */ public B setCompressionType(final CompressionType compressionType) { this.compressionType = compressionType; return asBuilder(); }
/** * Whether to include NULL byte as delimiter after each event (optional, default to false). * Useful for Graylog GELF TCP input. * * @return this builder */ public B setIncludeNullDelimiter(final boolean includeNullDelimiter) { this.includeNullDelimiter = includeNullDelimiter; return asBuilder(); }
/** * The value of the <code>host</code> property (optional, defaults to local host name). * * @return this builder */ public B setHost(final String host) { this.host = host; return asBuilder(); }
@Override public GelfLayout build() { return new GelfLayout(getConfiguration(), host, additionalFields, compressionType, compressionThreshold, includeStacktrace, includeThreadContext, includeNullDelimiter); }
/** * Additional fields to set on each log event. * * @return this builder */ public B setAdditionalFields(final KeyValuePair[] additionalFields) { this.additionalFields = additionalFields; return asBuilder(); } }
/** * Compress if data is larger than this number of bytes (optional, defaults to 1024). * * @return this builder */ public B setCompressionThreshold(final int compressionThreshold) { this.compressionThreshold = compressionThreshold; return asBuilder(); }
/** * Whether to include thread context as additional fields (optional, default to true). * * @return this builder */ public B setIncludeThreadContext(final boolean includeThreadContext) { this.includeThreadContext = includeThreadContext; return asBuilder(); }