Java 类org.apache.logging.log4j.core.config.plugins.PluginFactory 实例源码

项目:cas-5.1.0    文件:CloudWatchAppender.java   
/**
 * Create appender cloud watch appender.
 *
 * @param name                             the name
 * @param awsLogStreamName                 the aws log stream name
 * @param awsLogGroupName                  the aws log group name
 * @param awsLogStreamFlushPeriodInSeconds the aws log stream flush period in seconds
 * @param credentialAccessKey              the credential access key
 * @param credentialSecretKey              the credential secret key
 * @param awsLogRegionName                 the aws log region name
 * @param layout                           the layout
 * @return the cloud watch appender
 */
@PluginFactory
public static CloudWatchAppender createAppender(@PluginAttribute("name") final String name,
                                                @PluginAttribute("awsLogStreamName") final String awsLogStreamName,
                                                @PluginAttribute("awsLogGroupName") final String awsLogGroupName,
                                                @PluginAttribute("awsLogStreamFlushPeriodInSeconds") final String awsLogStreamFlushPeriodInSeconds,
                                                @PluginAttribute("credentialAccessKey") final String credentialAccessKey,
                                                @PluginAttribute("credentialSecretKey") final String credentialSecretKey,
                                                @PluginAttribute("awsLogRegionName") final String awsLogRegionName,
                                                @PluginElement("Layout") final Layout<Serializable> layout) {
    return new CloudWatchAppender(
            name,
            awsLogGroupName,
            awsLogStreamName,
            awsLogStreamFlushPeriodInSeconds,
            StringUtils.defaultIfBlank(credentialAccessKey, System.getProperty("AWS_ACCESS_KEY")),
            StringUtils.defaultIfBlank(credentialSecretKey, System.getProperty("AWS_SECRET_KEY")),
            StringUtils.defaultIfBlank(awsLogRegionName, System.getProperty("AWS_REGION_NAME")),
            layout);
}
项目: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);
}
项目:log4j2-jsonevent-layout    文件:JSONLog4j2Layout.java   
/**
 * 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);
}
项目:log4j-plugin-fluency    文件:FluencyConfig.java   
@PluginFactory
public static FluencyConfig createFluencyConfig(
        @PluginAttribute("ackResponseMode") final boolean ackResponseMode,
        @PluginAttribute("fileBackupDir") final String fileBackupDir,
        @PluginAttribute("bufferChunkInitialSize") final int bufferChunkInitialSize,
        @PluginAttribute("bufferChunkRetentionSize") final int bufferChunkRetentionSize,
        @PluginAttribute("maxBufferSize") final Long maxBufferSize,
        @PluginAttribute("waitUntilBufferFlushed") final int waitUntilBufferFlushed,
        @PluginAttribute("waitUntilFlusherTerminated") final int waitUntilFlusherTerminated,
        @PluginAttribute("flushIntervalMillis") final int flushIntervalMillis,
        @PluginAttribute("senderMaxRetryCount") final int senderMaxRetryCount) {
    FluencyConfig config = new FluencyConfig();
    config.ackResponseMode = ackResponseMode;
    config.fileBackupDir = fileBackupDir;
    config.bufferChunkInitialSize = bufferChunkInitialSize;
    config.bufferChunkRetentionSize = bufferChunkRetentionSize;
    config.maxBufferSize = maxBufferSize;
    config.waitUntilBufferFlushed = waitUntilBufferFlushed;
    config.waitUntilFlusherTerminated = waitUntilFlusherTerminated;
    config.flushIntervalMillis = flushIntervalMillis;
    config.senderMaxRetryCount = senderMaxRetryCount;
    return config;
}
项目:OneClient    文件:TextAreaAppender.java   
/**
 * Factory method. Log4j will parse the configuration and call this factory
 * method to construct the appender with
 * the configured attributes.
 *
 * @param name Name of appender
 * @param layout Log layout of appender
 * @param filter Filter for appender
 * @return The TextAreaAppender
 */
@PluginFactory
public static TextAreaAppender createAppender(
    @PluginAttribute("name")
        String name,
    @PluginElement("Layout")
        Layout<? extends Serializable> layout,
    @PluginElement("Filter")
    final Filter filter) {
    if (name == null) {
        LOGGER.error("No name provided for TextAreaAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }
    return new TextAreaAppender(name, filter, layout, true);
}
项目:CustomWorldGen    文件:TerminalConsoleAppender.java   
@PluginFactory
public static TerminalConsoleAppender createAppender(@PluginAttribute("name") String name, @PluginElement("Filters") Filter filter,
        @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginAttribute("ignoreExceptions") String ignore)
{

    if (name == null)
    {
        LOGGER.error("No name provided for TerminalConsoleAppender");
        return null;
    }
    if (layout == null)
    {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }

    boolean ignoreExceptions = parseBoolean(ignore, true);

    // This is handled by jline
    System.setProperty("log4j.skipJansi", "true");
    return new TerminalConsoleAppender(name, filter, layout, ignoreExceptions);
}
项目:logger-java-log4j    文件:ReportPortalLog4j2Appender.java   
@PluginFactory
public static ReportPortalLog4j2Appender createAppender(@PluginAttribute("name") String name,
        @PluginElement("filter") Filter filter,
        @PluginElement("layout") Layout<? extends Serializable> layout) {

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

    if (layout == null) {
        LOGGER.error("No layout provided for ReportPortalLog4j2Appender");
        return null;
    }
    return new ReportPortalLog4j2Appender(name, filter, layout);
}
项目: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);
}
项目:Brynhildr    文件:ConsoleLogAppender.java   
@PluginFactory
public static ConsoleLogAppender createAppender(@PluginAttribute("name") final String name, @PluginAttribute("ignoreExceptions") final String ignore, @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginElement("Filters") final Filter filter, @PluginAttribute("target") String target) {
    final boolean ignoreExceptions = Boolean.parseBoolean(ignore);
    if (name == null) {
        ConsoleLogAppender.LOGGER.error("No name provided for ConsoleLogAppender");
        return null;
    }
    if (target == null) {
        target = name;
    }
    ConsoleLogAppender.QUEUE_LOCK.writeLock().lock();
    BlockingQueue<String> queue = ConsoleLogAppender.QUEUES.get(target);
    if (queue == null) {
        queue = new LinkedBlockingQueue<>();
        ConsoleLogAppender.QUEUES.put(target, queue);
    }
    ConsoleLogAppender.QUEUE_LOCK.writeLock().unlock();
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, true, !Nukkit.useConsole, null, null);
    }
    return new ConsoleLogAppender(name, filter, layout, ignoreExceptions, queue);
}
项目:PVI    文件:WorkspaceLogAppender.java   
@PluginFactory
public static WorkspaceLogAppender createAppender(@PluginAttribute("name") String name,
                                                  @PluginElement("Layout") Layout<? extends Serializable> layout,
                                                  @PluginElement("Filter") final Filter filter) {

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

    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }

    return new WorkspaceLogAppender(name, filter, layout, true);
}
项目:slack-appender    文件:SlackAppender.java   
@PluginFactory
   public static SlackAppender createAppender(
    @PluginAttribute("name") String name,
    @PluginElement("Layout") Layout<? extends Serializable> layout,
    @PluginElement("Filter") final Filter filter,
    @PluginAttribute("webhookUrl") URL webhookUrl,
    @PluginAttribute("channel") String channel,
    @PluginAttribute(value = "username", defaultString = "Blazkowicz") String username,
    @PluginAttribute(value = "meltdownProtection", defaultBoolean = true) boolean meltdownProtection,
    @PluginAttribute(value = "similarMessageSize", defaultInt = 50) int similarMessageSize,
    @PluginAttribute(value = "timeBetweenSimilarLogsMs", defaultInt = 60000) int timeBetweenSimilarLogsMs,
    @PluginAttribute(value = "packagesToMute", defaultString = "") String packagesToMute,
    @PluginAttribute(value = "httpClientImpl", defaultString = "") String httpClientImpl) {
if (name == null) {
    LOGGER.error("No name provided for MyCustomAppenderImpl");
    return null;
}
if (layout == null) {
    layout = PatternLayout.createDefaultLayout();
}
Client client = findClientImpl(httpClientImpl);
SlackAppender slackAppender = new SlackAppender(name, filter, layout, webhookUrl, username, channel, meltdownProtection, similarMessageSize, timeBetweenSimilarLogsMs, client);
slackAppender.setPackagesToMute(packagesToMute);
return slackAppender;
   }
项目:Tank    文件:DebuggerAppender.java   
@PluginFactory
public static DebuggerAppender createAppender(@PluginAttribute("name") String name,
                                          @PluginElement("Layout") Layout<?> layout,
                                          @PluginElement("Filters") Filter filter,
                                          @PluginAttribute("ignoreExceptions") boolean ignoreExceptions) {

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

    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }
    return new DebuggerAppender(name, layout, filter, 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);
}
项目:chronix.examples    文件:TextAreaLogger.java   
/**
 * A custom appender needs to declare a factory method annotated with `@PluginFactory`.
 * Log4j will parse the configuration and call this factory method to construct an appender instance with
 * the configured attributes.
 *
 * @param name           - the logger name
 * @param layout         - the layout
 * @param filter         - the filter
 * @param otherAttribute - other attributes
 * @return a text area logger
 */
@PluginFactory
public static TextAreaLogger createAppender(
        @PluginAttribute("name") String name,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filter") final Filter filter,
        @PluginAttribute("otherAttribute") String otherAttribute) {
    if (name == null) {
        LOGGER.error("No name provided for MyCustomAppenderImpl");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }
    return new TextAreaLogger(name, filter, layout, true);
}
项目: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);
}
项目:mongofx    文件:MongoFXMessageAppender.java   
@PluginFactory
public static MongoFXMessageAppender createAppender(@PluginAttribute("name") String name,
    @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
    @PluginElement("Layout") Layout<? extends Serializable> layout,
    @PluginElement("Filters") Filter filter) {

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

  if (layout == null) {
    layout = PatternLayout.createDefaultLayout();
  }
  return new MongoFXMessageAppender(name, filter, layout, ignoreExceptions);
}
项目:stackify-log-log4j2    文件:StackifyLogAppender.java   
/**
    * Factory method for the appender
    *
    * @param name        The Appender name
    * @param filter      The Filter to associate with the Appender
    * @param apiUrl      API URL
    * @param apiKey      API Key
    * @param application Application name
    * @param environment Environment
 * @param skipJson    Mark messages w/ JSON w/ #SKIPJSON
    * @param maskEnabled Mask Enabled
    * @param masks       Masks
    * @return StackifyLogAppender
    */
   @PluginFactory
   public static StackifyLogAppender createAppender(@PluginAttribute("name") final String name,
                                                    @PluginElement("filters") final Filter filter,
                                                    @PluginAttribute("apiUrl") final String apiUrl,
                                                    @PluginAttribute("apiKey") final String apiKey,
                                                    @PluginAttribute("application") final String application,
                                                    @PluginAttribute("environment") final String environment,
                                                    @PluginAttribute("skipJson") final String skipJson,
                                                    @PluginAttribute("maskEnabled") final String maskEnabled,
                                                    @PluginElement("mask") final Mask[] masks) {
    return new StackifyLogAppender(name, filter, apiUrl, apiKey, application, environment,
            skipJson == null || Boolean.parseBoolean(skipJson),
            maskEnabled == null || Boolean.parseBoolean(maskEnabled),
            masks);
}
项目: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);
}
项目:Genji    文件:MemoryAppender.java   
@PluginFactory
public static MemoryAppender createAppender(
        @PluginAttribute("name") String name,
        @PluginElement("Layout") Layout<? extends Serializable> layout,
        @PluginElement("Filter") final Filter filter,
        @PluginAttribute("numberOfLines") String numberOfLines) {
    if (name == null) {
        LOGGER.error("No name provided for MemoryAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }
    if (numberOfLines != null) {
        logsize = Integer.valueOf(numberOfLines);
    }
    return new MemoryAppender(name, filter, layout, true);
}
项目:NeptuneMod    文件:TerminalConsoleAppender.java   
@PluginFactory
public static TerminalConsoleAppender createAppender(@PluginAttribute("name") String name, @PluginElement("Filters") Filter filter,
        @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginAttribute("ignoreExceptions") String ignore) {

    if (name == null) {
        LOGGER.error("No name provided for TerminalConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createLayout(null, null, null, null, null);
    }

    boolean ignoreExceptions = parseBoolean(ignore, true);

    // This is handled by jline
    System.setProperty("log4j.skipJansi", "true");
    return new TerminalConsoleAppender(name, filter, layout, ignoreExceptions);
}
项目:D3Launcher    文件:ConsoleWindowAppender.java   
@PluginFactory
public static ConsoleWindowAppender createAppender(@PluginAttribute("name") String name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, @PluginElement("Layout") Layout layout, @PluginElement("Filters") Filter filter)
{

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

    if (layout == null)
    {
        layout = PatternLayout.createDefaultLayout();
    }
    //noinspection unchecked
    return new ConsoleWindowAppender(name, filter, layout, ignoreExceptions);
}
项目:jesterj    文件:JesterJAppender.java   
@PluginFactory
public static JesterJAppender createAppender(@PluginAttribute("name") String name,
                                             @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
                                             @PluginElement("Layout") Layout layout,
                                             @PluginElement("Filters") Filter filter) {

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

  manager = createManager();
  if (manager == null) {
    return null;
  }
  if (layout == null) {
    layout = PatternLayout.createDefaultLayout();
  }
  cassandra.addStatement(FTI_INSERT_Q, INSERT_FTI);
  cassandra.addStatement(REG_INSERT_Q, INSERT_REG);
  return new JesterJAppender(name, layout, filter, manager, ignoreExceptions);
}
项目:SocialDataImporter    文件:SdiReportAppender.java   
/**
 * Factory method called by the log4j initialization framework
 * <p>
 * @param name
 * @param ignoreExceptions
 * @param layout
 * @param filter
 * @return
 */
@PluginFactory
public static SdiReportAppender createAppender( @PluginAttribute( "name" ) String name,
                                                @PluginAttribute( "ignoreExceptions" ) boolean ignoreExceptions,
                                                @PluginElement( "Layout" ) Layout<?> layout,
                                                @PluginElement( "Filters" ) Filter filter )
{

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

    return new SdiReportAppender( name, null, null );
}
项目: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);
}
项目:Pulse    文件:TerminalConsoleAppender.java   
@PluginFactory
public static TerminalConsoleAppender createAppender(
        @PluginElement("Layout") @Nullable Layout<? extends Serializable> layout,
        @PluginAttribute("name") String name,
        @PluginElement("Filter") Filter filter,
        @PluginAttribute(value = "ignoreExceptions", defaultBoolean = true) boolean ignoreExceptions) {

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

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

    // This is handled by jline
    System.setProperty("log4j.skipJansi", "true");
    return new TerminalConsoleAppender(name, filter, 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);
}
项目:jline-log4j2-appender    文件:JLineConsoleAppender.java   
@PluginFactory
public static JLineConsoleAppender 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.newBuilder().build();
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = t == null ? Target.SYSTEM_OUT : Target.valueOf(t);
    FactoryData data = new FactoryData(getStream(isFollow, target), layout);
    return new JLineConsoleAppender(name, layout, filter, getManager(isFollow, target, data), getHeldManager(isFollow, target, data), ignoreExceptions);
}
项目:logging-log4j2    文件:DirectWriteRolloverStrategy.java   
/**
 * 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
}
项目:log4j2    文件:Agent.java   
/**
 * Create an Agent.
 * @param host The host name.
 * @param port The port number.
 * @return The Agent.
 */
@PluginFactory
public static Agent createAgent(@PluginAttribute("host") String host,
        @PluginAttribute("port") final String port) {
    if (host == null) {
        host = DEFAULT_HOST;
    }

    int portNum;
    try {
        portNum = Integers.parseInt(port, DEFAULT_PORT);
    } catch (final Exception ex) {
        LOGGER.error("Error parsing port number " + port, ex);
        return null;
    }
    return new Agent(host, portNum);
}
项目:log4j2    文件:AppenderRef.java   
/**
 * Create an Appender reference.
 * @param ref The name of the Appender.
 * @param levelName The Level to filter against.
 * @param filter The filter(s) to use.
 * @return The name of the Appender.
 */
@PluginFactory
public static AppenderRef createAppenderRef(
        @PluginAttribute("ref") final String ref,
        @PluginAttribute("level") final String levelName,
        @PluginElement("Filters") final Filter filter) {

    if (ref == null) {
        LOGGER.error("Appender references must contain a reference");
        return null;
    }
    Level level = null;

    if (levelName != null) {
        level = Level.toLevel(levelName, null);
        if (level == null) {
            LOGGER.error("Invalid level " + levelName + " on Appender reference " + ref);
        }
    }

    return new AppenderRef(ref, level, filter);
}
项目: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);
}
项目:logging-log4j2    文件:DefaultRolloverStrategy.java   
/**
 * 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
}