本文整理匯總了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();
}
}
示例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;
}
}
示例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));
}
}
示例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");
}
示例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);
}
}
}
示例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);
}
示例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);
}
}