类org.apache.logging.log4j.core.util.Booleans源码实例Demo

下面列出了怎么用org.apache.logging.log4j.core.util.Booleans的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: logging-log4j2   文件: LoggerConfig.java
@PluginFactory
public static LoggerConfig createLogger(
        // @formatter:off
        @PluginAttribute final String additivity,
        @PluginAttribute final Level level,
        @PluginAttribute final String includeLocation,
        @PluginElement final AppenderRef[] refs,
        @PluginElement final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement final Filter filter) {
        // @formatter:on
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    final Level actualLevel = level == null ? Level.ERROR : level;
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, actualLevel, additive,
            properties, config, includeLocation(includeLocation, config));
}
 
源代码2 项目: logging-log4j2   文件: AsyncLoggerConfig.java
/**
 * @since 3.0
 */
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute final String additivity,
        @PluginAttribute final Level level,
        @PluginAttribute final String includeLocation,
        @PluginElement final AppenderRef[] refs,
        @PluginElement final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement final Filter filter) {
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    final Level actualLevel = level == null ? Level.ERROR : level;
    final boolean additive = Booleans.parseBoolean(additivity, true);
    return new AsyncLoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, actualLevel, additive,
            properties, config, AsyncLoggerConfig.includeLocation(includeLocation));
}
 
源代码3 项目: rollbar-java   文件: RollbarAppender.java
/**
 * Create appender plugin factory method.
 *
 * @param accessToken the Rollbar access token.
 * @param codeVersion the codeVersion.
 * @param endpoint the Rollbar endpoint to be used.
 * @param environment the environment.
 * @param language the language.
 * @param enabled to enable or disable Rollbar.
 * @param configProviderClassName The class name of the config provider implementation to get
 *     the configuration.
 * @param name the name.
 * @param layout the layout.
 * @param filter the filter.
 * @param ignore the ignore exceptions flag.
 * @return the rollbar appender.
 */
@PluginFactory
public static RollbarAppender createAppender(
    @PluginAttribute("accessToken") @Required final String accessToken,
    @PluginAttribute("codeVersion") final String codeVersion,
    @PluginAttribute("endpoint") final String endpoint,
    @PluginAttribute("environment") final String environment,
    @PluginAttribute("language") final String language,
    @PluginAttribute("enabled") final boolean enabled,
    @PluginAttribute("configProviderClassName") final String configProviderClassName,
    @PluginAttribute("name") @Required final String name,
    @PluginElement("Layout") Layout<? extends Serializable> layout,
    @PluginElement("Filter") Filter filter,
    @PluginAttribute("ignoreExceptions") final String ignore
) {

  ConfigProvider configProvider = ConfigProviderHelper
      .getConfigProvider(configProviderClassName);
  Config config;

  ConfigBuilder configBuilder = withAccessToken(accessToken)
      .codeVersion(codeVersion)
      .environment(environment)
      .endpoint(endpoint)
      .server(new ServerProvider())
      .language(language)
      .enabled(enabled);

  if (configProvider != null) {
    config = configProvider.provide(configBuilder);
  } else {
    config = configBuilder.build();
  }

  Rollbar rollbar = new Rollbar(config);

  boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

  return new RollbarAppender(name, filter, layout, ignoreExceptions, rollbar);
}
 
@PluginFactory
public static SystemdJournalAppender createAppender(@PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignoreExceptionsString,
        @PluginAttribute("logSource") final String logSourceString,
        @PluginAttribute("logStacktrace") final String logStacktraceString,
        @PluginAttribute("logLoggerName") final String logLoggerNameString,
        @PluginAttribute("logAppenderName") final String logAppenderNameString,
        @PluginAttribute("logThreadName") final String logThreadNameString,
        @PluginAttribute("logThreadContext") final String logThreadContextString,
        @PluginAttribute("threadContextPrefix") final String threadContextPrefix,
        @PluginAttribute("syslogIdentifier") final String syslogIdentifier,
        @PluginAttribute("syslogFacility") final String syslogFacility,
        @PluginElement("Layout") final Layout<?> layout,
        @PluginElement("Filter") final Filter filter,
        @PluginConfiguration final Configuration config) {
    final boolean ignoreExceptions = Booleans.parseBoolean(ignoreExceptionsString, true);
    final boolean logSource = Booleans.parseBoolean(logSourceString, false);
    final boolean logStacktrace = Booleans.parseBoolean(logStacktraceString, true);
    final boolean logThreadName = Booleans.parseBoolean(logThreadNameString, true);
    final boolean logLoggerName = Booleans.parseBoolean(logLoggerNameString, true);
    final boolean logAppenderName = Booleans.parseBoolean(logAppenderNameString, true);
    final boolean logThreadContext = Booleans.parseBoolean(logThreadContextString, true);

    if (name == null) {
        LOGGER.error("No name provided for SystemdJournalAppender");
        return null;
    }

    final SystemdJournalLibrary journalLibrary;
    try {
        journalLibrary = Native.loadLibrary("systemd", SystemdJournalLibrary.class);
    } catch (UnsatisfiedLinkError e) {
        throw new RuntimeException("Failed to load systemd library." +
            " Please note that JNA requires an executable temporary folder." +
            " It can be explicitly defined with -Djna.tmpdir", e);
    }

    return new SystemdJournalAppender(name, filter, layout, ignoreExceptions, journalLibrary, logSource, logStacktrace,
            logThreadName, logLoggerName, logAppenderName, logThreadContext, threadContextPrefix, syslogIdentifier, syslogFacility);
}
 
源代码5 项目: logging-log4j2   文件: SmtpAppender.java
/**
 * Create a SmtpAppender.
 * @deprecated Use {@link #newBuilder()} to create and configure a {@link Builder} instance.
 * @see Builder
 */
public static SmtpAppender createAppender(final Configuration config, final String name, final String to,
                                          final String cc, final String bcc, final String from,
                                          final String replyTo, final String subject, final String smtpProtocol,
                                          final String smtpHost, final String smtpPortStr,
                                          final String smtpUsername, final String smtpPassword,
                                          final String smtpDebug, final String bufferSizeStr,
                                          Layout<? extends Serializable> layout, Filter filter,
                                          final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for SmtpAppender");
        return null;
    }

    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final int smtpPort = AbstractAppender.parseInt(smtpPortStr, 0);
    final boolean isSmtpDebug = Boolean.parseBoolean(smtpDebug);
    final int bufferSize = bufferSizeStr == null ? DEFAULT_BUFFER_SIZE : Integer.parseInt(bufferSizeStr);

    if (layout == null) {
        layout = HtmlLayout.createDefaultLayout();
    }
    if (filter == null) {
        filter = ThresholdFilter.createFilter(null, null, null);
    }
    final Configuration configuration = config != null ? config : new DefaultConfiguration();

    final SmtpManager manager = SmtpManager.getSmtpManager(configuration, to, cc, bcc, from, replyTo, subject, smtpProtocol,
        smtpHost, smtpPort, smtpUsername, smtpPassword, isSmtpDebug, filter.toString(),  bufferSize, null);
    if (manager == null) {
        return null;
    }

    return new SmtpAppender(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY, manager);
}
 
@PluginFactory
public static LoghubAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginElement("Filter") final Filter filter,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginConfiguration final Configuration config,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginAttribute("project") final String project,
        @PluginAttribute("logStore") final String logStore,
        @PluginAttribute("endpoint") final String endpoint,
        @PluginAttribute("accessKeyId") final String accessKeyId,
        @PluginAttribute("accessKeySecret") final String accessKeySecret,
        @PluginAttribute("stsToken") final String stsToken,

        @PluginAttribute("totalSizeInBytes") final String  totalSizeInBytes,
        @PluginAttribute("maxBlockMs") final String  maxBlockMs,
        @PluginAttribute("ioThreadCount") final String  ioThreadCount,
        @PluginAttribute("batchSizeThresholdInBytes") final String  batchSizeThresholdInBytes,
        @PluginAttribute("batchCountThreshold") final String  batchCountThreshold,
        @PluginAttribute("lingerMs") final String  lingerMs,
        @PluginAttribute("retries") final String  retries,
        @PluginAttribute("baseRetryBackoffMs") final String  baseRetryBackoffMs,
        @PluginAttribute("maxRetryBackoffMs") final String maxRetryBackoffMs,

        @PluginAttribute("topic") final String topic,
        @PluginAttribute("source") final String source,
        @PluginAttribute("timeFormat") final String timeFormat,
        @PluginAttribute("timeZone") final String timeZone,
        @PluginAttribute("mdcFields") final String mdcFields) {

    Boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

    int maxBlockMsInt = parseStrToInt(maxBlockMs, 60);

    int baseRetryBackoffMsInt = parseStrToInt(baseRetryBackoffMs, 100);

    int maxRetryBackoffMsInt = parseStrToInt(maxRetryBackoffMs, 100);

    int lingerMsInt = parseStrToInt(lingerMs, 3000);

    int batchCountThresholdInt = parseStrToInt(batchCountThreshold, 4096);

    int batchSizeThresholdInBytesInt = parseStrToInt(batchSizeThresholdInBytes, 5 * 1024 * 1024);

    int totalSizeInBytesInt = parseStrToInt(totalSizeInBytes, 104857600);

    int retriesInt = parseStrToInt(retries, 3);

    int ioThreadCountInt = parseStrToInt(ioThreadCount, 8);

    String pattern = isStrEmpty(timeFormat) ? DEFAULT_TIME_FORMAT : timeFormat;
    String timeZoneInfo = isStrEmpty(timeZone) ? DEFAULT_TIME_ZONE : timeZone;
    DateTimeFormatter formatter = DateTimeFormat.forPattern(pattern).withZone(DateTimeZone.forID(timeZoneInfo));

    return new LoghubAppender(name, filter, layout, ignoreExceptions, project, logStore, endpoint,
            accessKeyId, accessKeySecret, stsToken,totalSizeInBytesInt,maxBlockMsInt,ioThreadCountInt,
            batchSizeThresholdInBytesInt,batchCountThresholdInt,lingerMsInt,retriesInt,
            baseRetryBackoffMsInt, maxRetryBackoffMsInt,topic, source, formatter,mdcFields);
}
 
 类所在包
 类方法
 同包方法