当前位置: 首页>>代码示例>>Java>>正文


Java Layout类代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.Layout的典型用法代码示例。如果您正苦于以下问题:Java Layout类的具体用法?Java Layout怎么用?Java Layout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Layout类属于org.apache.logging.log4j.core包,在下文中一共展示了Layout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:33,代码来源:CloudWatchAppender.java

示例2: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例3: RocketmqLog4j2Appender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例4: ElasticSearchRestAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例5: append

import org.apache.logging.log4j.core.Layout; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:25,代码来源:ListAppender.java

示例6: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例7: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例8: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例9: configureLogging

import org.apache.logging.log4j.core.Layout; //导入依赖的package包/类
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();
}
 
开发者ID:Steve973,项目名称:camel-standalone,代码行数:18,代码来源:Standalone.java

示例10: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例11: RocketmqLog4j2Appender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例12: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例13: SlackAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例14: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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

示例15: createAppender

import org.apache.logging.log4j.core.Layout; //导入依赖的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


注:本文中的org.apache.logging.log4j.core.Layout类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。