当前位置: 首页>>代码示例>>Java>>正文


Java PluginConfiguration类代码示例

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


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


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