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

项目: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);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:RocketmqLog4j2Appender.java   
protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
                                 boolean ignoreExceptions, String nameServerAddress, String producerGroup,
                                 String topic, String tag) {
    super(name, filter, layout, ignoreExceptions);
    this.producer = producer;
    this.topic = topic;
    this.tag = tag;
    this.nameServerAddress = nameServerAddress;
    this.producerGroup = producerGroup;
    try {
        this.producer = ProducerInstance.getInstance(this.nameServerAddress, this.producerGroup);
    } catch (Exception e) {
        ErrorHandler handler = this.getHandler();
        if (handler != null) {
            handler.error("Starting RocketmqLog4j2Appender [" + this.getName()
                    + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
        }
    }
}
项目:es-log4j2-appender    文件:ElasticSearchRestAppender.java   
/**
 * @param name The appender name
 * @param filter The appender filter
 * @param layout The layout
 * @param ignoreExceptions True if we are to ignore exceptions during logging
 * @param maxDelayTime Max delay time in millis before sending the messages to the database
 * @param maxBulkSize Max buffer size of messages held in memory before sending
 * @param dateFormat Format of the timestamp that is appended to the esIndex name while saving
 * @param index The ElasticSearch destination index
 * @param type The ElasticSearch destination type
 * @param bulkSender The Elastic bulk sender
 */
protected ElasticSearchRestAppender(String name, Filter filter, Layout<? extends Serializable> layout, final boolean ignoreExceptions,
        final long maxDelayTime, final int maxBulkSize, DateFormat dateFormat,
        String index, String type, BulkSender bulkSender) {
    super(name, filter, layout, ignoreExceptions);
    this.buffered = new ArrayList<>();
    this.timer = null;
    this.maxBulkSize = maxBulkSize;
    this.maxDelayTime = maxDelayTime;
    this.index = index;
    this.type = type;
    this.bulkSender = bulkSender;
    this.dateFormat = dateFormat;
    this.bulkItemFormat = String.format("{ \"index\" : { \"_index\" : \"%s%%s\", \"_type\" : \"%s\" } }%n%%s%n", index, type);
    this.validate();
}
项目:log4j2-extended-jsonlayout    文件:ListAppender.java   
@Override
public synchronized void append(final LogEvent event) {
    final Layout<? extends Serializable> layout = getLayout();
    if (layout == null) {
        if (event instanceof MutableLogEvent) {
            // must take snapshot or subsequent calls to logger.log() will modify this event
            events.add(((MutableLogEvent) event).createMemento());
        } else {
            events.add(event);
        }
    } else if (layout instanceof SerializedLayout) {
        final byte[] header = layout.getHeader();
        final byte[] content = layout.toByteArray(event);
        final byte[] record = new byte[header.length + content.length];
        System.arraycopy(header, 0, record, 0, header.length);
        System.arraycopy(content, 0, record, header.length, content.length);
        data.add(record);
    } else {
        write(layout.toByteArray(event));
    }
    if (countDownLatch != null) {
        countDownLatch.countDown();
    }
}
项目: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);
}
项目:camel-standalone    文件:Standalone.java   
protected void configureLogging() {
    final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
    final Configuration config = ctx.getConfiguration();
    Layout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, config, null, null,
            true, false, null, null);
    Appender appender = FileAppender.createAppender(workDir + "/logs/camel-standalone.log", "false", "false", "File", "true",
            "false", "false", "4000", layout, null, "false", null, config);
    appender.start();
    config.addAppender(appender);
    AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
    AppenderRef[] refs = new AppenderRef[] {ref};
    LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.INFO, "StandaloneFileLoggerConfig",
            "true", refs, null, config, null );
    loggerConfig.addAppender(appender, null, null);
    config.addLogger("StandaloneFileLoggerConfig", loggerConfig);
    ctx.updateLoggers();
}
项目: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);
}
项目:rocketmq    文件:RocketmqLog4j2Appender.java   
protected RocketmqLog4j2Appender(String name, Filter filter, Layout<? extends Serializable> layout,
    boolean ignoreExceptions, String nameServerAddress, String producerGroup,
    String topic, String tag) {
    super(name, filter, layout, ignoreExceptions);
    this.producer = producer;
    this.topic = topic;
    this.tag = tag;
    this.nameServerAddress = nameServerAddress;
    this.producerGroup = producerGroup;
    try {
        this.producer = ProducerInstance.getProducerInstance().getInstance(this.nameServerAddress, this.producerGroup);
    } catch (Exception e) {
        ErrorHandler handler = this.getHandler();
        if (handler != null) {
            handler.error("Starting RocketmqLog4j2Appender [" + this.getName()
                + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage());
        }
    }
}
项目: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   
private SlackAppender(String name,
          Filter filter,
          Layout<? extends Serializable> layout,
          final URL webhookUrl,
          final String username,
          final String channel,
          final boolean meltdownProtection,
          final int similarMessageSize,
          final int timeBetweenSimilarLogsMs,
          final Client client) {
super(name, filter, layout, true);
setWebhookUrl(webhookUrl);
this.username = username;
this.channel = channel;
this.meltdownProtection = meltdownProtection;
this.similarMessageSize = similarMessageSize;
this.timeBetweenSimilarLogsMs = timeBetweenSimilarLogsMs;
this.client = client;
   }
项目: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);
}
项目: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);
}
项目:elasticsearch-support-diagnostics    文件:Diagnostic.java   
private void createFileAppender(DiagnosticContext ctx) {

      String logDir = ctx.getTempDir() + SystemProperties.fileSeparator + "diagnostics.log";

      final LoggerContext context = (LoggerContext) LogManager.getContext(false);
      final Configuration config = context.getConfiguration();
      Layout layout = PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n", null, config, null,
         null,true, true, null, null );
      Appender appender = FileAppender.createAppender(logDir, "false", "false", "File", "true",
         "false", "false", "0", layout, null, "false", null, config);
      appender.start();
      config.addAppender(appender);
      AppenderRef ref = AppenderRef.createAppenderRef("File", null, null);
      AppenderRef[] refs = new AppenderRef[] {ref};

      config.getRootLogger().addAppender(appender, null, null);
      context.updateLoggers();
      Logger testLog = LogManager.getLogger();
      testLog.error("Testing");
   }
项目:log4j-systemd-journal-appender    文件:SystemdJournalAppender.java   
SystemdJournalAppender(String name, Filter filter, Layout layout, boolean ignoreExceptions,
                       SystemdJournalLibrary journalLibrary, boolean logSource, boolean logStacktrace, boolean logThreadName,
                       boolean logLoggerName, boolean logAppenderName, boolean logThreadContext, String threadContextPrefix, String syslogIdentifier) {
    super(name, filter, layout, ignoreExceptions);
    this.journalLibrary = journalLibrary;
    this.logSource = logSource;
    this.logStacktrace = logStacktrace;
    this.logThreadName = logThreadName;
    this.logLoggerName = logLoggerName;
    this.logAppenderName = logAppenderName;
    this.logThreadContext = logThreadContext;
    if (threadContextPrefix == null) {
        this.threadContextPrefix = "THREAD_CONTEXT_";
    } else {
        this.threadContextPrefix = normalizeKey(threadContextPrefix);
    }
    this.syslogIdentifier = syslogIdentifier;
}
项目: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    文件:SocketAppender.java   
/**
 * Creates an AbstractSocketManager for TCP, UDP, and SSL.
 *
 * @throws IllegalArgumentException
 *             if the protocol cannot be handled.
 */
protected static AbstractSocketManager createSocketManager(final String name, Protocol protocol, final String host,
        final int port, final int connectTimeoutMillis, final SslConfiguration sslConfig,
        final int reconnectDelayMillis, final boolean immediateFail, final Layout<? extends Serializable> layout,
        final int bufferSize, final SocketOptions socketOptions) {
    if (protocol == Protocol.TCP && sslConfig != null) {
        // Upgrade TCP to SSL if an SSL config is specified.
        protocol = Protocol.SSL;
    }
    if (protocol != Protocol.SSL && sslConfig != null) {
        LOGGER.info("Appender {} ignoring SSL configuration for {} protocol", name, protocol);
    }
    switch (protocol) {
    case TCP:
        return TcpSocketManager.getSocketManager(host, port, connectTimeoutMillis, reconnectDelayMillis,
                immediateFail, layout, bufferSize, socketOptions);
    case UDP:
        return DatagramSocketManager.getSocketManager(host, port, layout, bufferSize);
    case SSL:
        return SslSocketManager.getSocketManager(sslConfig, host, port, connectTimeoutMillis, reconnectDelayMillis,
                immediateFail, layout, bufferSize, socketOptions);
    default:
        throw new IllegalArgumentException(protocol.toString());
    }
}
项目:logging-log4j2    文件:ConsoleAppender.java   
/**
 * Creates a Console Appender.
 *
 * @param layout The layout to use (required).
 * @param filter The Filter or null.
 * @param targetStr The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
 * @param name The name of the Appender (required).
 * @param follow If true will follow changes to the underlying output stream.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise they
 *            are propagated to the caller.
 * @return The ConsoleAppender.
 * @deprecated Deprecated in 2.7; use {@link #newBuilder()}.
 */
@Deprecated
public static ConsoleAppender createAppender(Layout<? extends Serializable> layout,
        final Filter filter,
        final String targetStr,
        final String name,
        final String follow,
        final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for ConsoleAppender");
        return null;
    }
    if (layout == null) {
        layout = PatternLayout.createDefaultLayout();
    }
    final boolean isFollow = Boolean.parseBoolean(follow);
    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final Target target = targetStr == null ? DEFAULT_TARGET : Target.valueOf(targetStr);
    return new ConsoleAppender(name, layout, filter, getManager(target, isFollow, false, layout), ignoreExceptions, target);
}
项目:log4j2    文件:DefaultConfiguration.java   
/**
 * Constructor to create the default configuration.
 */
public DefaultConfiguration() {

    setName(DEFAULT_NAME);
    final Layout<? extends Serializable> layout =
            PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n", null, null, null, null);
    final Appender appender =
            ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "false", "true");
    appender.start();
    addAppender(appender);
    final LoggerConfig root = getRootLogger();
    root.addAppender(appender, null, null);

    final String levelName = PropertiesUtil.getProperties().getStringProperty(DEFAULT_LEVEL);
    final Level level = levelName != null && Level.valueOf(levelName) != null ?
        Level.valueOf(levelName) : Level.ERROR;
    root.setLevel(level);
}