• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PluginConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.logging.log4j.core.config.plugins.PluginConfiguration的典型用法代码示例。如果您正苦于以下问题:Java PluginConfiguration类的具体用法?Java PluginConfiguration怎么用?Java PluginConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PluginConfiguration类属于org.apache.logging.log4j.core.config.plugins包,在下文中一共展示了PluginConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates the layout.
 *
 * @param locationInfo the location info
 * @param singleLine the single line
 * @param htmlSafe the html safe
 * @param plainContextMap the plain context map
 * @param charset the charset
 * @param userFields the user fields
 * @return the JSON log 4 j 2 layout
 */
@PluginFactory
public static JSONLog4j2Layout createLayout(
	// @formatter:off
		@PluginConfiguration final Configuration config,
		@PluginAttribute("locationInfo") boolean locationInfo,
		@PluginAttribute("singleLine") boolean singleLine,
		@PluginAttribute("htmlSafe") boolean htmlSafe,
		@PluginAttribute("plainContextMap") boolean plainContextMap, 
		@PluginAttribute("charset") Charset charset,
		@PluginElement("UserFields") final UserField[] userFields
	// @formatter:on
	) {
	
	if(charset == null){
		charset = Charset.forName("UTF-8");
	}
	
	LOGGER.debug("Creating JSONLog4j2Layout {}",charset);
    return new JSONLog4j2Layout(locationInfo, singleLine, htmlSafe, plainContextMap, userFields, charset);
}
 
开发者ID:dubasdey,项目名称:log4j2-jsonevent-layout,代码行数:32,代码来源:JSONLog4j2Layout.java


示例2: createLogger

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute("additivity") final String additivity,
        @PluginAttribute("level") final String levelName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filters") final Filter filter) {
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    Level level;
    try {
        level = Level.toLevel(levelName, Level.ERROR);
    } catch (final Exception ex) {
        LOGGER.error(
                "Invalid Log level specified: {}. Defaulting to Error",
                levelName);
        level = Level.ERROR;
    }
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs,
            filter, level, additive, properties, config,
            includeLocation(includeLocation));
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:26,代码来源:LoggerConfig.java


示例3: createAppender

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Create a RewriteAppender.
 * @param name The name of the Appender.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param appenderRefs An array of Appender names to call.
 * @param config The Configuration.
 * @param rewritePolicy The policy to use to modify the event.
 * @param filter A Filter to filter events.
 * @return The created RewriteAppender.
 */
@PluginFactory
public static RewriteAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("AppenderRef") final AppenderRef[] appenderRefs,
        @PluginConfiguration final Configuration config,
        @PluginElement("RewritePolicy") final RewritePolicy rewritePolicy,
        @PluginElement("Filter") final Filter filter) {

    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    if (name == null) {
        LOGGER.error("No name provided for RewriteAppender");
        return null;
    }
    if (appenderRefs == null) {
        LOGGER.error("No appender references defined for RewriteAppender");
        return null;
    }
    return new RewriteAppender(name, filter, ignoreExceptions, appenderRefs, rewritePolicy, config);
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:32,代码来源:RewriteAppender.java


示例4: createAppender

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Create a RoutingAppender.
 * @param name The name of the Appender.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param routes The routing definitions.
 * @param config The Configuration (automatically added by the Configuration).
 * @param rewritePolicy A RewritePolicy, if any.
 * @param filter A Filter to restrict events processed by the Appender or null.
 * @return The RoutingAppender
 */
@PluginFactory
public static RoutingAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("Routes") final Routes routes,
        @PluginConfiguration final Configuration config,
        @PluginElement("RewritePolicy") final RewritePolicy rewritePolicy,
        @PluginElement("Filters") final Filter filter) {

    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    if (name == null) {
        LOGGER.error("No name provided for RoutingAppender");
        return null;
    }
    if (routes == null) {
        LOGGER.error("No routes defined for RoutingAppender");
        return null;
    }
    return new RoutingAppender(name, filter, ignoreExceptions, routes, rewritePolicy, config);
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:32,代码来源:RoutingAppender.java


示例5: createLogger

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute("additivity") final String additivity,
        @PluginAttribute("level") final String levelName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filters") final Filter filter) {
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    Level level;
    try {
        level = Level.toLevel(levelName, Level.ERROR);
    } catch (final Exception ex) {
        LOGGER.error(
                "Invalid Log level specified: {}. Defaulting to Error",
                levelName);
        level = Level.ERROR;
    }
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new AsyncLoggerConfig(LogManager.ROOT_LOGGER_NAME,
            appenderRefs, filter, level, additive, properties, config,
            includeLocation(includeLocation));
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:26,代码来源:AsyncLoggerConfig.java


示例6: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static Layout createLayout(
        @PluginElement("Replace") final RegexReplacement replace,
        @PluginConfiguration final Configuration configuration,
        @PluginAttribute(value = "charset", defaultString = "UTF-8") final Charset charset,
        @PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions,
        @PluginAttribute(value = "noConsoleNoAnsi", defaultBoolean = false) final boolean noConsoleNoAnsi,
        @PluginAttribute("header") final String header,
        @PluginAttribute("footer") final String footer) {
    return newBuilder()
            .withPattern(PATTERN)
            .withConfiguration(configuration)
            .withRegexReplacement(replace)
            .withCharset(charset)
            .withAlwaysWriteExceptions(alwaysWriteExceptions)
            .withNoConsoleNoAnsi(noConsoleNoAnsi)
            .withHeader(header)
            .withFooter(footer)
            .build();
}
 
开发者ID:greenbird,项目名称:mule-access-log,代码行数:21,代码来源:CombinedAccessLogPatternLayout.java


示例7: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static Layout createLayout(@PluginElement("Replace") final RegexReplacement replace,
                                  @PluginConfiguration final Configuration configuration,
                                  @PluginAttribute(value = "charset", defaultString = "UTF-8") final Charset charset,
                                  @PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions,
                                  @PluginAttribute(value = "noConsoleNoAnsi", defaultBoolean = false) final boolean noConsoleNoAnsi,
                                  @PluginAttribute("header") final String header,
                                  @PluginAttribute("footer") final String footer) {
    return newBuilder()
            .withPattern(PATTERN)
            .withConfiguration(configuration)
            .withRegexReplacement(replace)
            .withCharset(charset)
            .withAlwaysWriteExceptions(alwaysWriteExceptions)
            .withNoConsoleNoAnsi(noConsoleNoAnsi)
            .withHeader(header)
            .withFooter(footer)
            .build();
}
 
开发者ID:greenbird,项目名称:mule-access-log,代码行数:20,代码来源:CommonAccessLogPatternLayout.java


示例8: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static AbstractCsvLayout createLayout(
        // @formatter:off
        @PluginConfiguration final Configuration config,
        @PluginAttribute(value = "format", defaultString = DEFAULT_FORMAT) final String format,
        @PluginAttribute("delimiter") final Character delimiter,
        @PluginAttribute("escape") final Character escape,
        @PluginAttribute("quote") final Character quote,
        @PluginAttribute("quoteMode") final QuoteMode quoteMode,
        @PluginAttribute("nullString") final String nullString,
        @PluginAttribute("recordSeparator") final String recordSeparator,
        @PluginAttribute(value = "charset", defaultString = DEFAULT_CHARSET) final Charset charset,
        @PluginAttribute("header") final String header, 
        @PluginAttribute("footer") final String footer)
        // @formatter:on
{

    final CSVFormat csvFormat = createFormat(format, delimiter, escape, quote, quoteMode, nullString, recordSeparator);
    return new CsvParameterLayout(config, charset, csvFormat, header, footer);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:21,代码来源:CsvParameterLayout.java


示例9: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static CsvLogEventLayout createLayout(
        // @formatter:off
        @PluginConfiguration final Configuration config,
        @PluginAttribute(value = "format", defaultString = DEFAULT_FORMAT) final String format,
        @PluginAttribute("delimiter") final Character delimiter,
        @PluginAttribute("escape") final Character escape,
        @PluginAttribute("quote") final Character quote,
        @PluginAttribute("quoteMode") final QuoteMode quoteMode,
        @PluginAttribute("nullString") final String nullString,
        @PluginAttribute("recordSeparator") final String recordSeparator,
        @PluginAttribute(value = "charset", defaultString = DEFAULT_CHARSET) final Charset charset,
        @PluginAttribute("header") final String header,
        @PluginAttribute("footer") final String footer)
        // @formatter:on
{

    final CSVFormat csvFormat = createFormat(format, delimiter, escape, quote, quoteMode, nullString, recordSeparator);
    return new CsvLogEventLayout(config, charset, csvFormat, header, footer);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:21,代码来源:CsvLogEventLayout.java


示例10: createLogger

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Factory method to create a LoggerConfig.
 *
 * @param additivity True if additive, false otherwise.
 * @param level The Level to be associated with the Logger.
 * @param loggerName The name of the Logger.
 * @param includeLocation whether location should be passed downstream
 * @param refs An array of Appender names.
 * @param properties Properties to pass to the Logger.
 * @param config The Configuration.
 * @param filter A Filter.
 * @return A new LoggerConfig.
 * @deprecated Deprecated in 2.7; use {@link #createLogger(boolean, Level, String, String, AppenderRef[], Property[], Configuration, Filter)}
 */
@Deprecated
public static LoggerConfig createLogger(final String additivity,
        // @formatter:off
        final Level level,
        @PluginAttribute("name") final String loggerName,
        final String includeLocation,
        final AppenderRef[] refs,
        final Property[] properties,
        @PluginConfiguration final Configuration config,
        final Filter filter) {
        // @formatter:on
    if (loggerName == null) {
        LOGGER.error("Loggers cannot be configured without a name");
        return null;
    }

    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    final String name = loggerName.equals(ROOT) ? Strings.EMPTY : loggerName;
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new LoggerConfig(name, appenderRefs, filter, level, additive, properties, config,
            includeLocation(includeLocation));
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:38,代码来源:LoggerConfig.java


示例11: createAppender

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates a RewriteAppender.
 * @param name The name of the Appender.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param appenderRefs An array of Appender names to call.
 * @param config The Configuration.
 * @param rewritePolicy The policy to use to modify the event.
 * @param filter A Filter to filter events.
 * @return The created RewriteAppender.
 */
@PluginFactory
public static RewriteAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("AppenderRef") final AppenderRef[] appenderRefs,
        @PluginConfiguration final Configuration config,
        @PluginElement("RewritePolicy") final RewritePolicy rewritePolicy,
        @PluginElement("Filter") final Filter filter) {

    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    if (name == null) {
        LOGGER.error("No name provided for RewriteAppender");
        return null;
    }
    if (appenderRefs == null) {
        LOGGER.error("No appender references defined for RewriteAppender");
        return null;
    }
    return new RewriteAppender(name, filter, ignoreExceptions, appenderRefs, rewritePolicy, config);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:32,代码来源:RewriteAppender.java


示例12: createStrategy

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates the DirectWriteRolloverStrategy.
 *
 * @param maxFiles The maximum number of files that match the date portion of the pattern to keep.
 * @param compressionLevelStr The compression level, 0 (less) through 9 (more); applies only to ZIP files.
 * @param customActions custom actions to perform asynchronously after rollover
 * @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs
 * @param config The Configuration.
 * @return A DirectWriteRolloverStrategy.
 * @deprecated Since 2.9 Usage of Builder API is preferable
 */
@Deprecated
@PluginFactory
public static DirectWriteRolloverStrategy createStrategy(
        // @formatter:off
        @PluginAttribute("maxFiles") final String maxFiles,
        @PluginAttribute("compressionLevel") final String compressionLevelStr,
        @PluginElement("Actions") final Action[] customActions,
        @PluginAttribute(value = "stopCustomActionsOnError", defaultBoolean = true)
                final boolean stopCustomActionsOnError,
        @PluginConfiguration final Configuration config) {
        return newBuilder().withMaxFiles(maxFiles)
                .withCompressionLevelStr(compressionLevelStr)
                .withCustomActions(customActions)
                .withStopCustomActionsOnError(stopCustomActionsOnError)
                .withConfig(config)
                .build();
        // @formatter:on
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:DirectWriteRolloverStrategy.java


示例13: createPolicy

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates a ScheduledTriggeringPolicy.
 * 
 * @param configuration
 *            the Configuration.
 * @param evaluateOnStartup
 *            check if the file should be rolled over immediately.
 * @param schedule
 *            the cron expression.
 * @return a ScheduledTriggeringPolicy.
 */
@PluginFactory
public static CronTriggeringPolicy createPolicy(@PluginConfiguration final Configuration configuration,
        @PluginAttribute("evaluateOnStartup") final String evaluateOnStartup,
        @PluginAttribute("schedule") final String schedule) {
    CronExpression cronExpression;
    final boolean checkOnStartup = Boolean.parseBoolean(evaluateOnStartup);
    if (schedule == null) {
        LOGGER.info("No schedule specified, defaulting to Daily");
        cronExpression = getSchedule(defaultSchedule);
    } else {
        cronExpression = getSchedule(schedule);
        if (cronExpression == null) {
            LOGGER.error("Invalid expression specified. Defaulting to Daily");
            cronExpression = getSchedule(defaultSchedule);
        }
    }
    return new CronTriggeringPolicy(cronExpression, checkOnStartup, configuration);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:CronTriggeringPolicy.java


示例14: createStrategy

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates the DefaultRolloverStrategy.
 *
 * @param max The maximum number of files to keep.
 * @param min The minimum number of files to keep.
 * @param fileIndex If set to "max" (the default), files with a higher index will be newer than files with a smaller
 *            index. If set to "min", file renaming and the counter will follow the Fixed Window strategy.
 * @param compressionLevelStr The compression level, 0 (less) through 9 (more); applies only to ZIP files.
 * @param customActions custom actions to perform asynchronously after rollover
 * @param stopCustomActionsOnError whether to stop executing asynchronous actions if an error occurs
 * @param config The Configuration.
 * @return A DefaultRolloverStrategy.
 * @deprecated Since 2.9 Usage of Builder API is preferable
 */
@PluginFactory
@Deprecated
public static DefaultRolloverStrategy createStrategy(
        // @formatter:off
        @PluginAttribute("max") final String max,
        @PluginAttribute("min") final String min,
        @PluginAttribute("fileIndex") final String fileIndex,
        @PluginAttribute("compressionLevel") final String compressionLevelStr,
        @PluginElement("Actions") final Action[] customActions,
        @PluginAttribute(value = "stopCustomActionsOnError", defaultBoolean = true)
                final boolean stopCustomActionsOnError,
        @PluginConfiguration final Configuration config) {
    return DefaultRolloverStrategy.newBuilder()
                .withMin(min)
                .withMax(max)
                .withFileIndex(fileIndex)
                .withCompressionLevelStr(compressionLevelStr)
                .withCustomActions(customActions)
                .withStopCustomActionsOnError(stopCustomActionsOnError)
                .withConfig(config)
            .build();
        // @formatter:on
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:38,代码来源:DefaultRolloverStrategy.java


示例15: createFilter

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates the ScriptFilter.
 * @param script The script to run. The script must return a boolean value. Either script or scriptFile must be 
 *      provided.
 * @param match The action to take if a match occurs.
 * @param mismatch The action to take if no match occurs.
 * @param configuration the configuration 
 * @return A ScriptFilter.
 */
// TODO Consider refactoring to use AbstractFilter.AbstractFilterBuilder
@PluginFactory
public static ScriptFilter createFilter(
        @PluginElement("Script") final AbstractScript script,
        @PluginAttribute("onMatch") final Result match,
        @PluginAttribute("onMismatch") final Result mismatch,
        @PluginConfiguration final Configuration configuration) {

    if (script == null) {
        LOGGER.error("A Script, ScriptFile or ScriptRef element must be provided for this ScriptFilter");
        return null;
    }
    if (script instanceof ScriptRef) {
        if (configuration.getScriptManager().getScript(script.getName()) == null) {
            logger.error("No script with name {} has been declared.", script.getName());
            return null;
        }
    }

    return new ScriptFilter(script, configuration, match, mismatch);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:31,代码来源:ScriptFilter.java


示例16: createLogger

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute("additivity") final String additivity,
        @PluginAttribute("level") final String levelName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filter") final Filter filter) {
    final List<AppenderRef> appenderRefs = Arrays.asList(refs);
    Level level;
    try {
        level = Level.toLevel(levelName, Level.ERROR);
    } catch (final Exception ex) {
        LOGGER.error(
                "Invalid Log level specified: {}. Defaulting to Error",
                levelName);
        level = Level.ERROR;
    }
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new AsyncLoggerConfig(LogManager.ROOT_LOGGER_NAME,
            appenderRefs, filter, level, additive, properties, config,
            AsyncLoggerConfig.includeLocation(includeLocation));
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:26,代码来源:AsyncLoggerConfig.java


示例17: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates a pattern layout.
 *
 * @param pattern
 *        The pattern. If not specified, defaults to DEFAULT_CONVERSION_PATTERN.
 * @param patternSelector
 *        Allows different patterns to be used based on some selection criteria.
 * @param config
 *        The Configuration. Some Converters require access to the Interpolator.
 * @param replace
 *        A Regex replacement String.
 * @param charset
 *        The character set. The platform default is used if not specified.
 * @param alwaysWriteExceptions
 *        If {@code "true"} (default) exceptions are always written even if the pattern contains no exception tokens.
 * @param noConsoleNoAnsi
 *        If {@code "true"} (default is false) and {@link System#console()} is null, do not output ANSI escape codes
 * @param headerPattern
 *        The footer to place at the top of the document, once.
 * @param footerPattern
 *        The footer to place at the bottom of the document, once.
 * @return The PatternLayout.
 * @deprecated Use {@link #newBuilder()} instead. This will be private in a future version.
 */
@PluginFactory
@Deprecated
public static PatternLayout createLayout(
        @PluginAttribute(value = "pattern", defaultString = DEFAULT_CONVERSION_PATTERN) final String pattern,
        @PluginElement("PatternSelector") final PatternSelector patternSelector,
        @PluginConfiguration final Configuration config,
        @PluginElement("Replace") final RegexReplacement replace,
        // LOG4J2-783 use platform default by default, so do not specify defaultString for charset
        @PluginAttribute(value = "charset") final Charset charset,
        @PluginAttribute(value = "alwaysWriteExceptions", defaultBoolean = true) final boolean alwaysWriteExceptions,
        @PluginAttribute(value = "noConsoleNoAnsi") final boolean noConsoleNoAnsi,
        @PluginAttribute("header") final String headerPattern,
        @PluginAttribute("footer") final String footerPattern) {
    return newBuilder()
        .withPattern(pattern)
        .withPatternSelector(patternSelector)
        .withConfiguration(config)
        .withRegexReplacement(replace)
        .withCharset(charset)
        .withAlwaysWriteExceptions(alwaysWriteExceptions)
        .withNoConsoleNoAnsi(noConsoleNoAnsi)
        .withHeader(headerPattern)
        .withFooter(footerPattern)
        .build();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:50,代码来源:PatternLayout.java


示例18: createStrategy

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
/**
 * Create the DefaultRolloverStrategy.
 * @param max The maximum number of files to keep.
 * @param min The minimum number of files to keep.
 * @param fileIndex If set to "max" (the default), files with a higher index will be newer than files with a
 * smaller index. If set to "min", file renaming and the counter will follow the Fixed Window strategy.
 * @param compressionLevelStr The compression level, 0 (less) through 9 (more); applies only to ZIP files.
 * @param config The Configuration.
 * @return A DefaultRolloverStrategy.
 */
@PluginFactory
public static ZebraRolloverStrategy createStrategy(
        @PluginAttribute("max") final String max,
        @PluginAttribute("min") final String min,
        @PluginAttribute("fileIndex") final String fileIndex,
        @PluginAttribute("compressionLevel") final String compressionLevelStr,
        @PluginConfiguration final Configuration config) {
    final boolean useMax = fileIndex == null ? true : fileIndex.equalsIgnoreCase("max");
    int minIndex = MIN_WINDOW_SIZE;
    if (min != null) {
        minIndex = Integer.parseInt(min);
        if (minIndex < 1) {
            LOGGER.error("Minimum window size too small. Limited to " + MIN_WINDOW_SIZE);
            minIndex = MIN_WINDOW_SIZE;
        }
    }
    int maxIndex = DEFAULT_WINDOW_SIZE;
    if (max != null) {
        maxIndex = Integer.parseInt(max);
        if (maxIndex < minIndex) {
            maxIndex = minIndex < DEFAULT_WINDOW_SIZE ? DEFAULT_WINDOW_SIZE : minIndex;
            LOGGER.error("Maximum window size must be greater than the minimum windows size. Set to " + maxIndex);
        }
    }
    final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION);
    return new ZebraRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, config.getStrSubstitutor());
}
 
开发者ID:dianping,项目名称:zebra,代码行数:38,代码来源:ZebraRolloverStrategy.java


示例19: createLayout

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@PluginFactory
public static SimpleJSONLayout createLayout( //
		@PluginConfiguration final Configuration config, //
		@PluginAttribute(value = "locationInfo", defaultBoolean = false) final boolean locationInfo, //
		@PluginAttribute(value = "properties", defaultBoolean = true) final boolean properties, //
		@PluginAttribute(value = "complete", defaultBoolean = false) final boolean complete, //
		@PluginAttribute(value = "eventEol", defaultBoolean = true) final boolean eventEol, //
		@PluginAttribute(value = "header", defaultString = DEFAULT_HEADER) final String headerPattern, //
		@PluginAttribute(value = "footer", defaultString = DEFAULT_FOOTER) final String footerPattern, //
		@PluginAttribute(value = "charset", defaultString = "US-ASCII") final Charset charset, //
		@PluginElement("AdditionalField") final KeyValuePair[] additionalFields) {
	return new SimpleJSONLayout(config, locationInfo, properties, complete, eventEol, headerPattern,
			footerPattern, charset, additionalFields);
}
 
开发者ID:ggrandes,项目名称:log4j2-simplejson,代码行数:15,代码来源:SimpleJSONLayout.java


示例20: createAppender

import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; //导入依赖的package包/类
@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,
        @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;
    }

    SystemdJournalLibrary journalLibrary = (SystemdJournalLibrary) Native.loadLibrary("systemd",
            SystemdJournalLibrary.class);

    return new SystemdJournalAppender(name, filter, layout, ignoreExceptions, journalLibrary, logSource, logStacktrace,
            logThreadName, logLoggerName, logAppenderName, logThreadContext, threadContextPrefix, syslogIdentifier);
}
 
开发者ID:bwaldvogel,项目名称:log4j-systemd-journal-appender,代码行数:34,代码来源:SystemdJournalAppender.java



注:本文中的org.apache.logging.log4j.core.config.plugins.PluginConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebSocketTransportRegistration类代码示例发布时间:2022-05-21
下一篇:
Java SocketOptions类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap