當前位置: 首頁>>代碼示例>>Java>>正文


Java Filter類代碼示例

本文整理匯總了Java中org.apache.logging.log4j.core.Filter的典型用法代碼示例。如果您正苦於以下問題:Java Filter類的具體用法?Java Filter怎麽用?Java Filter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Filter類屬於org.apache.logging.log4j.core包,在下文中一共展示了Filter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:32,代碼來源:ConsoleAppender.java

示例2: RocketmqLog4j2Appender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
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());
        }
    }
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:20,代碼來源:RocketmqLog4j2Appender.java

示例3: ElasticSearchRestAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
/**
 * @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();
}
 
開發者ID:magrossi,項目名稱:es-log4j2-appender,代碼行數:28,代碼來源:ElasticSearchRestAppender.java

示例4: registerParent

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
protected final void registerParent(Class<? extends BaseLog4j2Configuration> clazz){
	BaseLog4j2Configuration configuration;
	try{
		configuration = clazz.newInstance();
	}catch(InstantiationException | IllegalAccessException e){
		throw new RuntimeException(e);
	}
	for(Appender appender : configuration.getAppenders()){
		addAppender(appender);
	}
	for(LoggerConfig loggerConfig : configuration.getLoggerConfigs()){
		addLoggerConfig(loggerConfig.getName(), loggerConfig.getLevel(), loggerConfig.isAdditive(), loggerConfig
				.getAppenders().values());
	}
	for(Filter filter : configuration.getFilters()){
		addFilter(filter);
	}
}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:19,代碼來源:BaseLog4j2Configuration.java

示例5: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:HearthProject,項目名稱:OneClient,代碼行數:28,代碼來源:TextAreaAppender.java

示例6: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:TerminalConsoleAppender.java

示例7: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:reportportal,項目名稱:logger-java-log4j,代碼行數:17,代碼來源:ReportPortalLog4j2Appender.java

示例8: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:MagicDroidX,項目名稱:Brynhildr,代碼行數:23,代碼來源:ConsoleLogAppender.java

示例9: RocketmqLog4j2Appender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
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());
        }
    }
}
 
開發者ID:apache,項目名稱:rocketmq,代碼行數:20,代碼來源:RocketmqLog4j2Appender.java

示例10: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:PlayPen,項目名稱:PVI,代碼行數:17,代碼來源:WorkspaceLogAppender.java

示例11: SlackAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
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;
   }
 
開發者ID:tobias-,項目名稱:slack-appender,代碼行數:20,代碼來源:SlackAppender.java

示例12: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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;
   }
 
開發者ID:tobias-,項目名稱:slack-appender,代碼行數:26,代碼來源:SlackAppender.java

示例13: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:17,代碼來源:DebuggerAppender.java

示例14: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:ChronixDB,項目名稱:chronix.examples,代碼行數:27,代碼來源:TextAreaLogger.java

示例15: createAppender

import org.apache.logging.log4j.core.Filter; //導入依賴的package包/類
@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);
}
 
開發者ID:daa84,項目名稱:mongofx,代碼行數:17,代碼來源:MongoFXMessageAppender.java


注:本文中的org.apache.logging.log4j.core.Filter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。