Java 类org.apache.logging.log4j.core.pattern.RegexReplacement 实例源码

项目:ColorConsole    文件:CommonLogInstaller.java   
public static PatternLayout createLayout(String logFormat) throws ReflectiveOperationException {
    try {
        Method builder = PatternLayout.class
                .getDeclaredMethod("createLayout", String.class, Configuration.class, RegexReplacement.class
                        , String.class, String.class);

        return (PatternLayout) builder.invoke(null, logFormat, new DefaultConfiguration(), null
                , Charset.defaultCharset().name(), "true");
    } catch (NoSuchMethodException methodEx) {
        return PatternLayout.newBuilder()
                .withCharset(Charset.defaultCharset())
                .withPattern(logFormat)
                .withConfiguration(new DefaultConfiguration())
                .withAlwaysWriteExceptions(true)
                .build();
    }
}
项目:mule-access-log    文件:CombinedAccessLogPatternLayout.java   
@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();
}
项目:mule-access-log    文件:CommonAccessLogPatternLayout.java   
@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();
}
项目:logging-log4j2    文件:PatternLayout.java   
/**
 * 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();
}
项目:log4j2    文件:PatternLayout.java   
/**
 * Constructs a EnhancedPatternLayout using the supplied conversion pattern.
 *
 * @param config The Configuration.
 * @param replace The regular expression to match.
 * @param pattern conversion pattern.
 * @param charset The character set.
 * @param alwaysWriteExceptions Whether or not exceptions should always be handled in this pattern (if {@code true},
 *                         exceptions will be written even if the pattern does not specify so).
 */
private PatternLayout(final Configuration config, final RegexReplacement replace, final String pattern,
                      final Charset charset, final boolean alwaysWriteExceptions) {
    super(charset);
    this.replace = replace;
    this.conversionPattern = pattern;
    this.config = config;
    this.alwaysWriteExceptions = alwaysWriteExceptions;
    final PatternParser parser = createPatternParser(config);
    formatters = parser.parse(pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, this.alwaysWriteExceptions);
}
项目:log4j2    文件:PatternLayout.java   
/**
 * Create a pattern layout.
 *
 * @param pattern The pattern. If not specified, defaults to DEFAULT_CONVERSION_PATTERN.
 * @param config The Configuration. Some Converters require access to the Interpolator.
 * @param replace A Regex replacement String.
 * @param charsetName The character set.
 * @param always If {@code "true"} (default) exceptions are always written even if the pattern contains no exception
 *               tokens.
 * @return The PatternLayout.
 */
@PluginFactory
public static PatternLayout createLayout(
        @PluginAttribute("pattern") final String pattern,
        @PluginConfiguration final Configuration config,
        @PluginElement("Replace") final RegexReplacement replace,
        @PluginAttribute("charset") final String charsetName,
        @PluginAttribute("alwaysWriteExceptions") final String always) {
    final Charset charset = Charsets.getSupportedCharset(charsetName);
    final boolean alwaysWriteExceptions = Booleans.parseBoolean(always, true);
    return new PatternLayout(
            config, replace, pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, charset, alwaysWriteExceptions
    );
}
项目:logging-log4j2    文件:PatternLayout.java   
/**
 * Constructs a PatternLayout using the supplied conversion pattern.
 *
 * @param config The Configuration.
 * @param replace The regular expression to match.
 * @param eventPattern conversion pattern.
 * @param patternSelector The PatternSelector.
 * @param charset The character set.
 * @param alwaysWriteExceptions Whether or not exceptions should always be handled in this pattern (if {@code true},
 *                         exceptions will be written even if the pattern does not specify so).
 * @param disableAnsi
 *            If {@code "true"}, do not output ANSI escape codes
 * @param noConsoleNoAnsi
 *            If {@code "true"} (default) and {@link System#console()} is null, do not output ANSI escape codes
 * @param headerPattern header conversion pattern.
 * @param footerPattern footer conversion pattern.
 */
private PatternLayout(final Configuration config, final RegexReplacement replace, final String eventPattern,
        final PatternSelector patternSelector, final Charset charset, final boolean alwaysWriteExceptions,
        final boolean disableAnsi, final boolean noConsoleNoAnsi, final String headerPattern,
        final String footerPattern) {
    super(config, charset,
            newSerializerBuilder()
                    .setConfiguration(config)
                    .setReplace(replace)
                    .setPatternSelector(patternSelector)
                    .setAlwaysWriteExceptions(alwaysWriteExceptions)
                    .setDisableAnsi(disableAnsi)
                    .setNoConsoleNoAnsi(noConsoleNoAnsi)
                    .setPattern(headerPattern)
                    .build(),
            newSerializerBuilder()
                    .setConfiguration(config)
                    .setReplace(replace)
                    .setPatternSelector(patternSelector)
                    .setAlwaysWriteExceptions(alwaysWriteExceptions)
                    .setDisableAnsi(disableAnsi)
                    .setNoConsoleNoAnsi(noConsoleNoAnsi)
                    .setPattern(footerPattern)
                    .build());
    this.conversionPattern = eventPattern;
    this.patternSelector = patternSelector;
    this.eventSerializer = newSerializerBuilder()
            .setConfiguration(config)
            .setReplace(replace)
            .setPatternSelector(patternSelector)
            .setAlwaysWriteExceptions(alwaysWriteExceptions)
            .setDisableAnsi(disableAnsi)
            .setNoConsoleNoAnsi(noConsoleNoAnsi)
            .setPattern(eventPattern)
            .setDefaultPattern(DEFAULT_CONVERSION_PATTERN)
            .build();
}
项目:logging-log4j2    文件:PatternLayout.java   
/**
 * Deprecated, use {@link #newSerializerBuilder()} instead.
 *
 * @param configuration
 * @param replace
 * @param pattern
 * @param defaultPattern
 * @param patternSelector
 * @param alwaysWriteExceptions
 * @param noConsoleNoAnsi
 * @return a new Serializer.
 * @deprecated Use {@link #newSerializerBuilder()} instead.
 */
@Deprecated
public static Serializer createSerializer(final Configuration configuration, final RegexReplacement replace,
        final String pattern, final String defaultPattern, final PatternSelector patternSelector,
        final boolean alwaysWriteExceptions, final boolean noConsoleNoAnsi) {
    final SerializerBuilder builder = newSerializerBuilder();
    builder.setAlwaysWriteExceptions(alwaysWriteExceptions);
    builder.setConfiguration(configuration);
    builder.setDefaultPattern(defaultPattern);
    builder.setNoConsoleNoAnsi(noConsoleNoAnsi);
    builder.setPattern(pattern);
    builder.setPatternSelector(patternSelector);
    builder.setReplace(replace);
    return builder.build();
}
项目:jamocha    文件:LayoutAdapter.java   
public static PatternLayout createLayout(final Configuration config, final boolean plain) {
    return PatternLayout.createLayout(
            plain ? PatternLayout.DEFAULT_CONVERSION_PATTERN : PatternLayout.SIMPLE_CONVERSION_PATTERN,
            (PatternSelector) null, config, (RegexReplacement) null, Charsets.UTF_8, true, true, "", "");
}
项目:WorldDownloader-Serverside-Companion    文件:PatternLayout.java   
public static PatternLayout createLayout(final String pattern,
        Configuration config, final RegexReplacement replace,
        final String charsetName, final String always) {
    throw new AssertionError("This is test code");
}
项目:logging-log4j2    文件:PatternLayout.java   
private PatternSerializer(final PatternFormatter[] formatters, final RegexReplacement replace) {
    super();
    this.formatters = formatters;
    this.replace = replace;
}
项目:logging-log4j2    文件:PatternLayout.java   
public SerializerBuilder setReplace(final RegexReplacement replace) {
    this.replace = replace;
    return this;
}
项目:logging-log4j2    文件:PatternLayout.java   
private PatternSelectorSerializer(final PatternSelector patternSelector, final RegexReplacement replace) {
    super();
    this.patternSelector = patternSelector;
    this.replace = replace;
}
项目:logging-log4j2    文件:PatternLayout.java   
/**
 * @param regexReplacement
 *        A Regex replacement
 */
public Builder withRegexReplacement(final RegexReplacement regexReplacement) {
    this.regexReplacement = regexReplacement;
    return this;
}