本文整理汇总了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);
}
示例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());
}
}
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}