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


Java Layout.getHeader方法代碼示例

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


在下文中一共展示了Layout.getHeader方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: OutputStreamManager

import org.apache.logging.log4j.core.Layout; //導入方法依賴的package包/類
protected OutputStreamManager(final OutputStream os, final String streamName, final Layout<?> layout) {
    super(streamName);
    this.os = os;
    if (layout != null) {
        this.footer = layout.getFooter();
        this.header = layout.getHeader();
        if (this.header != null) {
            try {
                this.os.write(header, 0, header.length);
            } catch (final IOException ioe) {
                LOGGER.error("Unable to write header", ioe);
            }
        }
    } else {
        this.footer = null;
        this.header = null;
    }
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:19,代碼來源:OutputStreamManager.java

示例3: 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) {
        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));
    }
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:17,代碼來源:ListAppender.java

示例4: OutputStreamManager

import org.apache.logging.log4j.core.Layout; //導入方法依賴的package包/類
/**
 * @since 2.6
 * @deprecated
 */
@Deprecated
protected OutputStreamManager(final OutputStream os, final String streamName, final Layout<?> layout,
        final boolean writeHeader, final ByteBuffer byteBuffer) {
    super(null, streamName);
    this.outputStream = os;
    this.layout = layout;
    if (writeHeader && layout != null) {
        final byte[] header = layout.getHeader();
        if (header != null) {
            try {
                getOutputStream().write(header, 0, header.length);
            } catch (final IOException e) {
                logError("Unable to write header", e);
            }
        }
    }
    this.byteBuffer = Objects.requireNonNull(byteBuffer, "byteBuffer");
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:23,代碼來源:OutputStreamManager.java

示例5: ListAppender

import org.apache.logging.log4j.core.Layout; //導入方法依賴的package包/類
public ListAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean newline,
                    final boolean raw) {
    super(name, filter, layout);
    this.newLine = newline;
    this.raw = raw;
    if (layout != null && !(layout instanceof SerializedLayout)) {
        final byte[] bytes = layout.getHeader();
        if (bytes != null) {
            write(bytes);
        }
    }
}
 
開發者ID:savantly-net,項目名稱:log4j2-extended-jsonlayout,代碼行數:13,代碼來源:ListAppender.java

示例6: tryAppend

import org.apache.logging.log4j.core.Layout; //導入方法依賴的package包/類
private void tryAppend(final LogEvent event) throws ExecutionException, InterruptedException, TimeoutException {
    final Layout<? extends Serializable> layout = getLayout();
    byte[] data;
    if (layout instanceof SerializedLayout) {
        final byte[] header = layout.getHeader();
        final byte[] body = layout.toByteArray(event);
        data = new byte[header.length + body.length];
        System.arraycopy(header, 0, data, 0, header.length);
        System.arraycopy(body, 0, data, header.length, body.length);
    } else {
        data = layout.toByteArray(event);
    }
    manager.send(data);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:15,代碼來源:KafkaAppender.java

示例7: writeHeader

import org.apache.logging.log4j.core.Layout; //導入方法依賴的package包/類
protected void writeHeader(final Layout<?> layout, final OutputStream out) throws IOException {
    final byte[] header = layout.getHeader();
    if (header != null) {
        out.write(header);
    }
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:7,代碼來源:SMTPManager.java


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