/** * Add a root logger to this fraction * @param level the log level * @return this fraction */ public LoggingFraction rootLogger(String level) { return rootLogger(level, null); }
/** * Add a root logger to this fraction * @param level the log level * @param handlers a list of handlers * @return this fraction */ public LoggingFraction rootLogger(String level, String... handlers) { rootLogger( new RootLogger().level(level) .handlers(new ArrayList<>(Arrays.asList(handlers))) ); return this; }
/** * Add a root logger to this fraction * * @param level the log level * @param handlers a list of handlers * @return this fraction */ public LoggingFraction rootLogger(Level level, String... handlers) { rootLogger(new RootLogger().level(level) .handlers(handlers)); return this; }
/** * Add a root logger to this fraction * * @param level the log level * @param handlers a list of handlers * @return this fraction */ public LoggingFraction rootLogger(Level level, String... handlers) { rootLogger(new RootLogger().level(level) .handlers(handlers)); return this; }
/** * Create a default logging fraction for the specified level. * * @return The fully-configured fraction. */ public static LoggingFraction createDefaultLoggingFraction(Level level) { return new LoggingFraction() .defaultColorFormatter() .consoleHandler(level, COLOR_PATTERN) .rootLogger(level, CONSOLE); }
/** * Create a default logging fraction for the specified level. * * @return The fully-configured fraction. */ public static LoggingFraction createDefaultLoggingFraction(String level) { return new LoggingFraction() .defaultColorFormatter() .consoleHandler(level, COLOR_PATTERN) .rootLogger(level, CONSOLE); }
public LoggingFraction applyDefaults(Level level) { defaultColorFormatter() .consoleHandler(Level.ALL, COLOR_PATTERN) .rootLogger(level, CONSOLE); Properties allProps = System.getProperties(); for (String name : allProps.stringPropertyNames()) { if (isSimpleLoggerName(name)) { String logger = name.substring((LoggingProperties.LOGGING + ".").length()); try { Level loggerLevel = Level.valueOf(allProps.getProperty(name).trim().toUpperCase()); logger(logger, (l) -> { l.level(loggerLevel); l.category(logger); }); } catch (IllegalArgumentException e) { // apparently wasn't a logging category+level, ignore. } } } return this; }
@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())); }