/** * Add a CustomHandler to this logger * * @param name the name of the handler * @param module the module that the handler uses * @param className the handler class name * @param properties properties for the handler * @param formatter a pattern string for the formatter * @return this fraction */ public LoggingFraction customHandler(String name, String module, String className, Properties properties, String formatter) { Map<Object, Object> handlerProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); handlerProperties.put(nextElement, properties.getProperty(nextElement)); } customHandler(new CustomHandler(name) .module(module) .attributeClass(className) .formatter(formatter) .properties(handlerProperties)); return this; }
/** * Add a CustomHandler to this logger * * @param name the name of the handler * @param module the module that the handler uses * @param className the handler class name * @param properties properties for the handler * @param formatter a pattern string for the formatter * @return this fraction */ public LoggingFraction customHandler(String name, String module, String className, Properties properties, String formatter) { Map handlerProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); handlerProperties.put(nextElement, properties.getProperty(nextElement)); } customHandler( new CustomHandler(name) .module(module) .attributeClass(className) .formatter(formatter) .properties(handlerProperties) ); return this; }
/** * Add a CustomHandler to this logger * * @param name the name of the handler * @param module the module that the handler uses * @param className the handler class name * @param properties properties for the handler * @param formatter a pattern string for the formatter * @return this fraction */ public LoggingFraction customHandler(String name, String module, String className, Properties properties, String formatter) { Map<Object, Object> handlerProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); handlerProperties.put(nextElement, properties.getProperty(nextElement)); } customHandler(new CustomHandler(name) .module(module) .attributeClass(className) .formatter(formatter) .properties(handlerProperties)); return this; }
@Override public void customize() { if (logstash.enabled()) { Properties handlerProps = new Properties(); handlerProps.put("hostname", this.logstash.hostname()); handlerProps.put("port", "" + this.logstash.port()); final CustomHandler<?> logstashHandler = new CustomHandler<>("logstash-handler") .module("org.jboss.logmanager.ext") .attributeClass("org.jboss.logmanager.ext.handlers.SocketHandler") .namedFormatter("logstash") .properties(handlerProps) .level(this.logstash.level()); this.logging .customFormatter("logstash", "org.jboss.logmanager.ext", "org.jboss.logmanager.ext.formatters.LogstashFormatter", this.logstash.formatterProperties()) .customHandler(logstashHandler) .subresources() .rootLogger() .handler(logstashHandler.getKey()); } } }
@Override public void customize() { if (logstash.enabled()) { Properties handlerProps = new Properties(); handlerProps.put("hostname", this.logstash.hostname()); handlerProps.put("port", "" + this.logstash.port()); final CustomHandler<?> logstashHandler = new CustomHandler<>("logstash-handler") .module("org.jboss.logmanager.ext") .attributeClass("org.jboss.logmanager.ext.handlers.SocketHandler") .namedFormatter("logstash") .properties(handlerProps) .level(this.logstash.level()); this.logging .customFormatter("logstash", "org.jboss.logmanager.ext", "org.jboss.logmanager.ext.formatters.LogstashFormatter", this.logstash.formatterProperties()) .customHandler(logstashHandler) .subresources() .rootLogger() .handler(logstashHandler.getKey()); } } }
@Override public void initialize(Container.InitContext initContext) { final CustomHandler<?> logstashHandler = new CustomHandler<>("logstash-handler") .module("org.jboss.logmanager.ext") .attributeClass("org.jboss.logmanager.ext.handlers.SocketHandler") .namedFormatter("logstash") .properties(handlerProperties); initContext.fraction(new LoggingFraction() .customFormatter("logstash", "org.jboss.logmanager.ext", "org.jboss.logmanager.ext.formatters.LogstashFormatter", this.formatterProperties) .customHandler(logstashHandler) .rootLogger(this.level, logstashHandler.getKey())); }