@PluginAttribute("facility") String facility, @PluginAttribute("filterStackTrace") String filterStackTrace,
@PluginAttribute("mdcProfiling") String mdcProfiling,
@PluginAttribute("maximumMessageSize") String maximumMessageSize,
@PluginAttribute("testSenderClass") String testSenderClass) {
MdcGelfMessageAssembler mdcGelfMessageAssembler = new MdcGelfMessageAssembler();
if (name == null) {
LOGGER.error("No name provided for " + GelfLogAppender.class.getSimpleName());
return null;
}
if (Strings.isEmpty(host) && Strings.isEmpty(graylogHost)) {
LOGGER.error("No host provided for " + GelfLogAppender.class.getSimpleName());
return null;
}
if (Strings.isNotEmpty(host)) {
mdcGelfMessageAssembler.setHost(host);
}
if (Strings.isNotEmpty(graylogHost)) {
mdcGelfMessageAssembler.setHost(graylogHost);
}
if (Strings.isNotEmpty(port)) {
mdcGelfMessageAssembler.setPort(Integer.parseInt(port));
}
if (Strings.isNotEmpty(graylogPort)) {
mdcGelfMessageAssembler.setPort(Integer.parseInt(graylogPort));
}
if (facility != null) {
mdcGelfMessageAssembler.setFacility(facility);
}
if (extractStackTrace != null) {
mdcGelfMessageAssembler.setExtractStackTrace(extractStackTrace.equals("true"));
}
if (filterStackTrace != null) {
mdcGelfMessageAssembler.setFilterStackTrace(filterStackTrace.equals("true"));
}
if (mdcProfiling != null) {
mdcGelfMessageAssembler.setMdcProfiling(mdcProfiling.equals("true"));
}
if (maximumMessageSize != null) {
mdcGelfMessageAssembler.setMaximumMessageSize(Integer.parseInt(maximumMessageSize));
}
configureFields(mdcGelfMessageAssembler, fields);
GelfLogAppender result = new GelfLogAppender(name, filter, mdcGelfMessageAssembler);