/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @return This fraction. */ public LoggingFraction customFormatter(String name, String module, String className) { return customFormatter(name, module, className, null); }
/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @return This fraction. */ public LoggingFraction customFormatter(String name, String module, String className) { return customFormatter(name, module, className, null); }
/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @return This fraction. */ public LoggingFraction customFormatter(String name, String module, String className) { return customFormatter(name, module, className, null); }
/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @param properties the properties * @return this fraction */ public LoggingFraction customFormatter(String name, String module, String className, Properties properties) { Map<Object, Object> formatterProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); formatterProperties.put(nextElement, properties.getProperty(nextElement)); } customFormatter(new CustomFormatter(name) .module(module) .attributeClass(className) .properties(formatterProperties)); return this; }
/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @param properties the properties * @return this fraction */ public LoggingFraction customFormatter(String name, String module, String className, Properties properties) { Map<Object, Object> formatterProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); formatterProperties.put(nextElement, properties.getProperty(nextElement)); } customFormatter(new CustomFormatter(name) .module(module) .attributeClass(className) .properties(formatterProperties)); return this; }
/** * Add a CustomFormatter to this logger * * @param name the name of the formatter * @param module the module that the logging handler depends on * @param className the logging handler class to be used * @param properties the properties * @return this fraction */ public LoggingFraction customFormatter(String name, String module, String className, Properties properties) { Map formatterProperties = new HashMap<>(); final Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { final String nextElement = (String) names.nextElement(); formatterProperties.put(nextElement, properties.getProperty(nextElement)); } customFormatter( new CustomFormatter(name) .module(module) .attributeClass(className) .properties(formatterProperties) ); 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())); }