Java 类org.apache.logging.log4j.core.helpers.Booleans 实例源码

项目:Uranium    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:ThermosRebased    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Thermos    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:KCauldron    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:CauldronGit    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Cauldron-Old    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Cauldron-Reloaded    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:FFoKC    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:CraftBukkit    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Craftbukkit    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Tweakkit-Server    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:Cauldron    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:SpigotSource    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:log4j2    文件:LoggerConfig.java   
@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));
}
项目:log4j2    文件:RewriteAppender.java   
/**
 * 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);
}
项目:log4j2    文件:ConsoleAppender.java   
/**
 * Create a Console Appender.
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param t The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param follow If true will follow changes to the underlying output stream.
 * @param name The name of the Appender (required).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The ConsoleAppender.
 */
@PluginFactory
public static ConsoleAppender createAppender(
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("target") final String t,
        @PluginAttribute("name") final String name,
        @PluginAttribute("follow") final String follow,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    return new ConsoleAppender(name, layout, filter, getManager(isFollow, target, layout), ignoreExceptions);
}
项目:log4j2    文件:RoutingAppender.java   
/**
 * 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);
}
项目:log4j2    文件:AsyncLoggerConfig.java   
@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));
}
项目:log4j2    文件:LoggerConfig.java   
/**
 * Factory method to create a LoggerConfig.
 *
 * @param additivity True if additive, false otherwise.
 * @param levelName 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.
 */
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute("additivity") final String additivity,
        @PluginAttribute("level") final String levelName,
        @PluginAttribute("name") final String loggerName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filters") final Filter filter) {
    if (loggerName == null) {
        LOGGER.error("Loggers cannot be configured without a name");
        return null;
    }

    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 String name = loggerName.equals("root") ? "" : loggerName;
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new LoggerConfig(name, appenderRefs, filter, level, additive,
            properties, config, includeLocation(includeLocation));
}
项目:log4j2    文件:AsyncAppender.java   
/**
 * Create an AsyncAppender.
 * @param appenderRefs The Appenders to reference.
 * @param errorRef An optional Appender to write to if the queue is full or other errors occur.
 * @param blocking True if the Appender should wait when the queue is full. The default is true.
 * @param size The size of the event queue. The default is 128.
 * @param name The name of the Appender.
 * @param includeLocation whether to include location information. The default is false.
 * @param filter The Filter or null.
 * @param config The Configuration.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The AsyncAppender.
 */
@PluginFactory
public static AsyncAppender createAppender(@PluginElement("AppenderRef") final AppenderRef[] appenderRefs,
        @PluginAttribute("errorRef") @PluginAliases("error-ref") final String errorRef,
        @PluginAttribute("blocking") final String blocking, 
        @PluginAttribute("bufferSize") final String size,
        @PluginAttribute("name") final String name,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("Filter") final Filter filter, 
        @PluginConfiguration final Configuration config,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for AsyncAppender");
        return null;
    }
    if (appenderRefs == null) {
        LOGGER.error("No appender references provided to AsyncAppender {}", name);
    }

    final boolean isBlocking = Booleans.parseBoolean(blocking, true);
    final int queueSize = AbstractAppender.parseInt(size, DEFAULT_QUEUE_SIZE);
    final boolean isIncludeLocation = Boolean.parseBoolean(includeLocation);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

    return new AsyncAppender(name, filter, appenderRefs, errorRef,
            queueSize, isBlocking, ignoreExceptions, config, isIncludeLocation);
}
项目:log4j2    文件:JMSQueueAppender.java   
/**
 * Create a JMSQueueAppender.
 * @param name The name of the Appender.
 * @param factoryName The fully qualified class name of the InitialContextFactory.
 * @param providerURL The URL of the provider to use.
 * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
 * will create a URL context factory
 * @param securityPrincipalName The name of the identity of the Principal.
 * @param securityCredentials The security credentials of the Principal.
 * @param factoryBindingName The name to locate in the Context that provides the QueueConnectionFactory.
 * @param queueBindingName The name to use to locate the Queue.
 * @param userName The user ID to use to create the Queue Connection.
 * @param password The password to use to create the Queue Connection.
 * @param layout The layout to use (defaults to SerializedLayout).
 * @param filter The Filter or null.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The JMSQueueAppender.
 */
@PluginFactory
public static JMSQueueAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("factoryName") final String factoryName,
        @PluginAttribute("providerURL") final String providerURL,
        @PluginAttribute("urlPkgPrefixes") final String urlPkgPrefixes,
        @PluginAttribute("securityPrincipalName") final String securityPrincipalName,
        @PluginAttribute("securityCredentials") final String securityCredentials,
        @PluginAttribute("factoryBindingName") final String factoryBindingName,
        @PluginAttribute("queueBindingName") final String queueBindingName,
        @PluginAttribute("userName") final String userName,
        @PluginAttribute("password") final String password,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filter") final Filter filter,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for JMSQueueAppender");
        return null;
    }
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final JMSQueueManager manager = JMSQueueManager.getJMSQueueManager(factoryName, providerURL, urlPkgPrefixes,
        securityPrincipalName, securityCredentials, factoryBindingName, queueBindingName, userName, password);
    if (manager == null) {
        return null;
    }
    if (layout == null) {
        layout = SerializedLayout.createLayout();
    }
    return new JMSQueueAppender(name, filter, layout, manager, ignoreExceptions);
}
项目:log4j2    文件:FailoverAppender.java   
/**
 * Create a Failover Appender.
 * @param name The name of the Appender (required).
 * @param primary The name of the primary Appender (required).
 * @param failovers The name of one or more Appenders to fail over to (at least one is required).
 * @param retryIntervalString The retry intervalMillis.
 * @param config The current Configuration (passed by the Configuration when the appender is created).
 * @param filter A Filter (optional).
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The FailoverAppender that was created.
 */
@PluginFactory
public static FailoverAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("primary") final String primary,
        @PluginElement("Failovers") final String[] failovers,
        @PluginAttribute("retryInterval") final String retryIntervalString,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("ignoreExceptions") final String ignore) {
    if (name == null) {
        LOGGER.error("A name for the Appender must be specified");
        return null;
    }
    if (primary == null) {
        LOGGER.error("A primary Appender must be specified");
        return null;
    }
    if (failovers == null || failovers.length == 0) {
        LOGGER.error("At least one failover Appender must be specified");
        return null;
    }

    final int seconds = parseInt(retryIntervalString, DEFAULT_INTERVAL_SECONDS);
    int retryIntervalMillis;
    if (seconds >= 0) {
        retryIntervalMillis = seconds * Constants.MILLIS_IN_SECONDS;
    } else {
        LOGGER.warn("Interval " + retryIntervalString + " is less than zero. Using default");
        retryIntervalMillis = DEFAULT_INTERVAL_SECONDS * Constants.MILLIS_IN_SECONDS;
    }

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

    return new FailoverAppender(name, filter, primary, failovers, retryIntervalMillis, config, ignoreExceptions);
}
项目:log4j2    文件:NoSQLAppender.java   
/**
 * Factory method for creating a NoSQL appender within the plugin manager.
 *
 * @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 filter The filter, if any, to use.
 * @param bufferSize If an integer greater than 0, this causes the appender to buffer log events and flush whenever
 *                   the buffer reaches this size.
 * @param provider The NoSQL provider that provides connections to the chosen NoSQL database.
 * @return a new NoSQL appender.
 */
@PluginFactory
public static NoSQLAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("Filter") final Filter filter,
        @PluginAttribute("bufferSize") final String bufferSize,
        @PluginElement("NoSqlProvider") final NoSQLProvider<?> provider) {
    if (provider == null) {
        LOGGER.error("NoSQL provider not specified for appender [{}].", name);
        return null;
    }

    final int bufferSizeInt = AbstractAppender.parseInt(bufferSize, 0);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

    final String managerName = "noSqlManager{ description=" + name + ", bufferSize=" + bufferSizeInt
            + ", provider=" + provider + " }";

    final NoSQLDatabaseManager<?> manager = NoSQLDatabaseManager.getNoSQLDatabaseManager(
            managerName, bufferSizeInt, provider
    );
    if (manager == null) {
        return null;
    }

    return new NoSQLAppender(name, filter, ignoreExceptions, manager);
}
项目:log4j2    文件:JDBCAppender.java   
/**
 * Factory method for creating a JDBC appender within the plugin manager.
 *
 * @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 filter The filter, if any, to use.
 * @param connectionSource The connections source from which database connections should be retrieved.
 * @param bufferSize If an integer greater than 0, this causes the appender to buffer log events and flush whenever
 *                   the buffer reaches this size.
 * @param tableName The name of the database table to insert log events into.
 * @param columnConfigs Information about the columns that log event data should be inserted into and how to insert
 *                      that data.
 * @return a new JDBC appender.
 */
@PluginFactory
public static JDBCAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("Filter") final Filter filter,
        @PluginElement("ConnectionSource") final ConnectionSource connectionSource,
        @PluginAttribute("bufferSize") final String bufferSize,
        @PluginAttribute("tableName") final String tableName,
        @PluginElement("ColumnConfigs") final ColumnConfig[] columnConfigs) {

    final int bufferSizeInt = AbstractAppender.parseInt(bufferSize, 0);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

    final StringBuilder managerName = new StringBuilder("jdbcManager{ description=").append(name)
            .append(", bufferSize=").append(bufferSizeInt).append(", connectionSource=")
            .append(connectionSource.toString()).append(", tableName=").append(tableName).append(", columns=[ ");

    int i = 0;
    for (final ColumnConfig column : columnConfigs) {
        if (i++ > 0) {
            managerName.append(", ");
        }
        managerName.append(column.toString());
    }

    managerName.append(" ] }");

    final JDBCDatabaseManager manager = JDBCDatabaseManager.getJDBCDatabaseManager(
            managerName.toString(), bufferSizeInt, connectionSource, tableName, columnConfigs
    );
    if (manager == null) {
        return null;
    }

    return new JDBCAppender(name, filter, ignoreExceptions, manager);
}
项目:log4j2    文件:JMSTopicAppender.java   
/**
 * Create a JMSTopicAppender.
 * @param name The name of the Appender.
 * @param factoryName The fully qualified class name of the InitialContextFactory.
 * @param providerURL The URL of the provider to use.
 * @param urlPkgPrefixes A colon-separated list of package prefixes for the class name of the factory class that
 * will create a URL context factory
 * @param securityPrincipalName The name of the identity of the Principal.
 * @param securityCredentials The security credentials of the Principal.
 * @param factoryBindingName The name to locate in the Context that provides the TopicConnectionFactory.
 * @param topicBindingName The name to use to locate the Topic.
 * @param userName The userid to use to create the Topic Connection.
 * @param password The password to use to create the Topic Connection.
 * @param layout The layout to use (defaults to SerializedLayout).
 * @param filter The Filter or null.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @return The JMSTopicAppender.
 */
@PluginFactory
public static JMSTopicAppender createAppender(
        @PluginAttribute("name") final String name,
        @PluginAttribute("factoryName") final String factoryName,
        @PluginAttribute("providerURL") final String providerURL,
        @PluginAttribute("urlPkgPrefixes") final String urlPkgPrefixes,
        @PluginAttribute("securityPrincipalName") final String securityPrincipalName,
        @PluginAttribute("securityCredentials") final String securityCredentials,
        @PluginAttribute("factoryBindingName") final String factoryBindingName,
        @PluginAttribute("topicBindingName") final String topicBindingName,
        @PluginAttribute("userName") final String userName,
        @PluginAttribute("password") final String password,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("ignoreExceptions") final String ignore) {

    if (name == null) {
        LOGGER.error("No name provided for JMSQueueAppender");
        return null;
    }
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final JMSTopicManager manager = JMSTopicManager.getJMSTopicManager(factoryName, providerURL, urlPkgPrefixes,
        securityPrincipalName, securityCredentials, factoryBindingName, topicBindingName, userName, password);
    if (manager == null) {
        return null;
    }
    if (layout == null) {
        layout = SerializedLayout.createLayout();
    }
    return new JMSTopicAppender(name, filter, layout, manager, ignoreExceptions);
}
项目:log4j2    文件:AsyncLoggerConfig.java   
/**
 * Factory method to create a LoggerConfig.
 *
 * @param additivity True if additive, false otherwise.
 * @param levelName The Level to be associated with the Logger.
 * @param loggerName The name of the Logger.
 * @param includeLocation "true" if 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.
 */
@PluginFactory
public static LoggerConfig createLogger(
        @PluginAttribute("additivity") final String additivity,
        @PluginAttribute("level") final String levelName,
        @PluginAttribute("name") final String loggerName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filters") final Filter filter) {
    if (loggerName == null) {
        LOGGER.error("Loggers cannot be configured without a name");
        return null;
    }

    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 String name = loggerName.equals("root") ? "" : loggerName;
    final boolean additive = Booleans.parseBoolean(additivity, true);

    return new AsyncLoggerConfig(name, appenderRefs, filter, level,
            additive, properties, config, includeLocation(includeLocation));
}
项目:log4j2    文件:RFC5424Layout.java   
/**
 * Create the RFC 5424 Layout.
 *
 * @param facility         The Facility is used to try to classify the message.
 * @param id               The default structured data id to use when formatting according to RFC 5424.
 * @param ein              The IANA enterprise number.
 * @param includeMDC       Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog
 *                         record. Defaults to "true:.
 * @param mdcId            The id to use for the MDC Structured Data Element.
 * @param mdcPrefix        The prefix to add to MDC key names.
 * @param eventPrefix      The prefix to add to event key names.
 * @param includeNL        If true, a newline will be appended to the end of the syslog record. The default is false.
 * @param escapeNL         String that should be used to replace newlines within the message text.
 * @param appName          The value to use as the APP-NAME in the RFC 5424 syslog record.
 * @param msgId            The default value to be used in the MSGID field of RFC 5424 syslog records.
 * @param excludes         A comma separated list of MDC keys that should be excluded from the LogEvent.
 * @param includes         A comma separated list of MDC keys that should be included in the FlumeEvent.
 * @param required         A comma separated list of MDC keys that must be present in the MDC.
 * @param exceptionPattern The pattern for formatting exceptions.
 * @param useTLSMessageFormat If true the message will be formatted according to RFC 5425.
 * @param loggerFields     Container for the KeyValuePairs containing the patterns
 * @param config           The Configuration. Some Converters require access to the Interpolator.
 * @return An RFC5424Layout.
 */
@PluginFactory
public static RFC5424Layout createLayout(
        @PluginAttribute("facility") final String facility,
        @PluginAttribute("id") final String id,
        @PluginAttribute("enterpriseNumber") final String ein,
        @PluginAttribute("includeMDC") final String includeMDC,
        @PluginAttribute("mdcId") String mdcId,
        @PluginAttribute("mdcPrefix") final String mdcPrefix,
        @PluginAttribute("eventPrefix") final String eventPrefix,
        @PluginAttribute("newLine") final String includeNL,
        @PluginAttribute("newLineEscape") final String escapeNL,
        @PluginAttribute("appName") final String appName,
        @PluginAttribute("messageId") final String msgId,
        @PluginAttribute("mdcExcludes") final String excludes,
        @PluginAttribute("mdcIncludes") String includes,
        @PluginAttribute("mdcRequired") final String required,
        @PluginAttribute("exceptionPattern") final String exceptionPattern,
        @PluginAttribute("useTLSMessageFormat") final String useTLSMessageFormat, // RFC 5425
        @PluginElement("LoggerFields") final LoggerFields[] loggerFields,
        @PluginConfiguration final Configuration config) {
    final Charset charset = Charsets.UTF_8;
    if (includes != null && excludes != null) {
        LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
        includes = null;
    }
    final Facility f = Facility.toFacility(facility, Facility.LOCAL0);
    final int enterpriseNumber = Integers.parseInt(ein, DEFAULT_ENTERPRISE_NUMBER);
    final boolean isMdc = Booleans.parseBoolean(includeMDC, true);
    final boolean includeNewLine = Boolean.parseBoolean(includeNL);
    final boolean useTlsMessageFormat = Booleans.parseBoolean(useTLSMessageFormat, false);
    if (mdcId == null) {
        mdcId = DEFAULT_MDCID;
    }

    return new RFC5424Layout(config, f, id, enterpriseNumber, isMdc, includeNewLine, escapeNL, mdcId, mdcPrefix,
            eventPrefix, appName, msgId, excludes, includes, required, charset, exceptionPattern,
            useTlsMessageFormat, loggerFields);
}
项目:log4j2    文件:LoggerFields.java   
/**
 * Create a LoggerFields from KeyValuePairs.
 * 
 * @param keyValuePairs
 *            An array of KeyValuePairs.
 * @param sdId
 *            The SD-ID in an SD-ELEMENT
 * @param enterpriseId
 *            The IANA assigned enterprise number
 * @param discardIfAllFieldsAreEmpty
 *            this SD-ELEMENT should be discarded if all fields are empty
 * @return A LoggerFields instance containing a Map<String, String>.
 */
@PluginFactory
public static LoggerFields createLoggerFields(@PluginElement("LoggerFields") final KeyValuePair[] keyValuePairs,
        @PluginAttribute("sdId") final String sdId, @PluginAttribute("enterpriseId") String enterpriseId,
        @PluginAttribute("discardIfAllFieldsAreEmpty") String discardIfAllFieldsAreEmpty) {
    final Map<String, String> map = new HashMap<String, String>();

    for (final KeyValuePair keyValuePair : keyValuePairs) {
        map.put(keyValuePair.getKey(), keyValuePair.getValue());
    }

    final boolean discardIfEmpty = Booleans.parseBoolean(discardIfAllFieldsAreEmpty, false);
    return new LoggerFields(map, sdId, enterpriseId, discardIfEmpty);
}
项目: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
    );
}
项目:log4j2    文件:RollingFileAppender.java   
/**
 * Create a RollingFileAppender.
 * @param fileName The name of the file that is actively written to. (required).
 * @param filePattern The pattern of the file name to use on rollover. (required).
 * @param append If true, events are appended to the file. If false, the file
 * is overwritten when opened. Defaults to "true"
 * @param name The name of the Appender (required).
 * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
 * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
 * @param policy The triggering policy. (required).
 * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
 * @param layout The layout to use (defaults to the default PatternLayout).
 * @param filter The Filter or null.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
 * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
 * @param config The Configuration.
 * @return A RollingFileAppender.
 */
@PluginFactory
public static RollingFileAppender createAppender(
        @PluginAttribute("fileName") final String fileName,
        @PluginAttribute("filePattern") final String filePattern,
        @PluginAttribute("append") final String append,
        @PluginAttribute("name") final String name,
        @PluginAttribute("bufferedIO") final String bufferedIO,
        @PluginAttribute("immediateFlush") final String immediateFlush,
        @PluginElement("Policy") final TriggeringPolicy policy,
        @PluginElement("Strategy") RolloverStrategy strategy,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filter") final Filter filter,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginAttribute("advertise") final String advertise,
        @PluginAttribute("advertiseURI") final String advertiseURI,
        @PluginConfiguration final Configuration config) {

    final boolean isAppend = Booleans.parseBoolean(append, true);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
    final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
    final boolean isAdvertise = Boolean.parseBoolean(advertise);
    if (name == null) {
        LOGGER.error("No name provided for FileAppender");
        return null;
    }

    if (fileName == null) {
        LOGGER.error("No filename was provided for FileAppender with name "  + name);
        return null;
    }

    if (filePattern == null) {
        LOGGER.error("No filename pattern provided for FileAppender with name "  + name);
        return null;
    }

    if (policy == null) {
        LOGGER.error("A TriggeringPolicy must be provided");
        return null;
    }

    if (strategy == null) {
        strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
                String.valueOf(Deflater.DEFAULT_COMPRESSION), config);
    }

    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }

    final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend,
        isBuffered, policy, strategy, advertiseURI, layout);
    if (manager == null) {
        return null;
    }

    return new RollingFileAppender(name, layout, filter, manager, fileName, filePattern,
            ignoreExceptions, isFlush, isAdvertise ? config.getAdvertiser() : null);
}
项目:log4j2    文件:RandomAccessFileAppender.java   
/**
 * Create a File Appender.
 *
 * @param fileName The name and path of the file.
 * @param append "True" if the file should be appended to, "false" if it
 *            should be overwritten. The default is "true".
 * @param name The name of the Appender.
 * @param immediateFlush "true" if the contents should be flushed on every
 *            write, "false" otherwise. The default is "true".
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param layout The layout to use to format the event. If no layout is
 *            provided the default PatternLayout will be used.
 * @param filter The filter, if any, to use.
 * @param advertise "true" if the appender configuration should be
 *            advertised, "false" otherwise.
 * @param advertiseURI The advertised URI which can be used to retrieve the
 *            file contents.
 * @param config The Configuration.
 * @return The FileAppender.
 */
@PluginFactory
public static RandomAccessFileAppender createAppender(
        @PluginAttribute("fileName") final String fileName,
        @PluginAttribute("append") final String append,
        @PluginAttribute("name") final String name,
        @PluginAttribute("immediateFlush") final String immediateFlush,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("advertise") final String advertise,
        @PluginAttribute("advertiseURI") final String advertiseURI,
        @PluginConfiguration final Configuration config) {

    final boolean isAppend = Booleans.parseBoolean(append, true);
    final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final boolean isAdvertise = Boolean.parseBoolean(advertise);

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

    if (fileName == null) {
        LOGGER.error("No filename provided for FileAppender with name "
                + name);
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }
    final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(
            fileName, isAppend, isFlush, advertiseURI, layout
    );
    if (manager == null) {
        return null;
    }

    return new RandomAccessFileAppender(
            name, layout, filter, manager, fileName, ignoreExceptions, isFlush,
            isAdvertise ? config.getAdvertiser() : null
    );
}
项目:log4j2    文件:ColumnConfig.java   
/**
 * Factory method for creating a column config within the plugin manager.
 *
 * @param config The configuration object
 * @param name The name of the database column as it exists within the database table.
 * @param pattern The {@link PatternLayout} pattern to insert in this column. Mutually exclusive with
 *                {@code literalValue!=null} and {@code eventTimestamp=true}
 * @param literalValue The literal value to insert into the column as-is without any quoting or escaping. Mutually
 *                     exclusive with {@code pattern!=null} and {@code eventTimestamp=true}.
 * @param eventTimestamp If {@code "true"}, indicates that this column is a date-time column in which the event
 *                       timestamp should be inserted. Mutually exclusive with {@code pattern!=null} and
 *                       {@code literalValue!=null}.
 * @param unicode If {@code "true"}, indicates that the column is a unicode String.
 * @param clob If {@code "true"}, indicates that the column is a character LOB (CLOB).
 * @return the created column config.
 */
@PluginFactory
public static ColumnConfig createColumnConfig(
        @PluginConfiguration final Configuration config,
        @PluginAttribute("name") final String name,
        @PluginAttribute("pattern") final String pattern,
        @PluginAttribute("literal") final String literalValue,
        @PluginAttribute("isEventTimestamp") final String eventTimestamp,
        @PluginAttribute("isUnicode") final String unicode,
        @PluginAttribute("isClob") final String clob) {
    if (Strings.isEmpty(name)) {
        LOGGER.error("The column config is not valid because it does not contain a column name.");
        return null;
    }

    final boolean isPattern = Strings.isNotEmpty(pattern);
    final boolean isLiteralValue = Strings.isNotEmpty(literalValue);
    final boolean isEventTimestamp = Boolean.parseBoolean(eventTimestamp);
    final boolean isUnicode = Booleans.parseBoolean(unicode, true);
    final boolean isClob = Boolean.parseBoolean(clob);

    if ((isPattern && isLiteralValue) || (isPattern && isEventTimestamp) || (isLiteralValue && isEventTimestamp)) {
        LOGGER.error("The pattern, literal, and isEventTimestamp attributes are mutually exclusive.");
        return null;
    }

    if (isEventTimestamp) {
        return new ColumnConfig(name, null, null, true, false, false);
    }
    if (isLiteralValue) {
        return new ColumnConfig(name, null, literalValue, false, false, false);
    }
    if (isPattern) {
        return new ColumnConfig(
                name, PatternLayout.createLayout(pattern, config, null, null, "false"), null, false, isUnicode,
                isClob
        );
    }

    LOGGER.error("To configure a column you must specify a pattern or literal or set isEventDate to true.");
    return null;
}
项目:log4j2    文件:FileAppender.java   
/**
 * Create a File Appender.
 * @param fileName The name and path of the file.
 * @param append "True" if the file should be appended to, "false" if it should be overwritten.
 * The default is "true".
 * @param locking "True" if the file should be locked. The default is "false".
 * @param name The name of the Appender.
 * @param immediateFlush "true" if the contents should be flushed on every write, "false" otherwise. The default
 * is "true".
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param bufferedIO "true" if I/O should be buffered, "false" otherwise. The default is "true".
 * @param layout The layout to use to format the event. If no layout is provided the default PatternLayout
 * will be used.
 * @param filter The filter, if any, to use.
 * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
 * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
 * @param config The Configuration
 * @return The FileAppender.
 */
@PluginFactory
public static FileAppender createAppender(
        @PluginAttribute("fileName") final String fileName,
        @PluginAttribute("append") final String append,
        @PluginAttribute("locking") final String locking,
        @PluginAttribute("name") final String name,
        @PluginAttribute("immediateFlush") final String immediateFlush,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginAttribute("bufferedIO") final String bufferedIO,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("advertise") final String advertise,
        @PluginAttribute("advertiseURI") final String advertiseURI,
        @PluginConfiguration final Configuration config) {

    final boolean isAppend = Booleans.parseBoolean(append, true);
    final boolean isLocking = Boolean.parseBoolean(locking);
    boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
    final boolean isAdvertise = Boolean.parseBoolean(advertise);
    if (isLocking && isBuffered) {
        if (bufferedIO != null) {
            LOGGER.warn("Locking and buffering are mutually exclusive. No buffering will occur for " + fileName);
        }
        isBuffered = false;
    }
    final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);

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

    if (fileName == null) {
        LOGGER.error("No filename provided for FileAppender with name "  + name);
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }

    final FileManager manager = FileManager.getFileManager(fileName, isAppend, isLocking, isBuffered, advertiseURI,
        layout);
    if (manager == null) {
        return null;
    }


    return new FileAppender(name, layout, filter, manager, fileName, ignoreExceptions, isFlush,
            isAdvertise ? config.getAdvertiser() : null);
}
项目:log4j2    文件:SocketAppender.java   
/**
 *
 * @param host The name of the host to connect to.
 * @param portNum The port to connect to on the target host.
 * @param protocol The Protocol to use.
 * @param delay The interval in which failed writes should be retried.
 * @param immediateFail True if the write should fail if no socket is immediately available.
 * @param name The name of the Appender.
 * @param immediateFlush "true" if data should be flushed on each write.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param layout The layout to use (defaults to SerializedLayout).
 * @param filter The Filter or null.
 * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
 * @param config The Configuration
 * @return A SocketAppender.
 */
@PluginFactory
public static SocketAppender createAppender(
        @PluginAttribute("host") final String host,
        @PluginAttribute("port") final String portNum,
        @PluginAttribute("protocol") final String protocol,
        @PluginAttribute("reconnectionDelay") final String delay,
        @PluginAttribute("immediateFail") final String immediateFail,
        @PluginAttribute("name") final String name,
        @PluginAttribute("immediateFlush") final String immediateFlush,
        @PluginAttribute("ignoreExceptions") final String ignore,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filters") final Filter filter,
        @PluginAttribute("advertise") final String advertise,
        @PluginConfiguration final Configuration config) {

    boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
    final boolean isAdvertise = Boolean.parseBoolean(advertise);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final boolean fail = Booleans.parseBoolean(immediateFail, true);
    final int reconnectDelay = AbstractAppender.parseInt(delay, 0);
    final int port = AbstractAppender.parseInt(portNum, 0);
    if (layout == null) {
        layout = SerializedLayout.createLayout();
    }

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

    final Protocol p = EnglishEnums.valueOf(Protocol.class, protocol != null ? protocol : Protocol.TCP.name());
    if (p.equals(Protocol.UDP)) {
        isFlush = true;
    }

    final AbstractSocketManager manager = createSocketManager(p, host, port, reconnectDelay, fail, layout);
    if (manager == null) {
        return null;
    }

    return new SocketAppender(name, layout, filter, manager, ignoreExceptions, isFlush,
            isAdvertise ? config.getAdvertiser() : null);
}