本文整理汇总了Java中org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Log4jLogEvent.Builder方法的具体用法?Java Log4jLogEvent.Builder怎么用?Java Log4jLogEvent.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.impl.Log4jLogEvent
的用法示例。
在下文中一共展示了Log4jLogEvent.Builder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newEvent
import org.apache.logging.log4j.core.impl.Log4jLogEvent; //导入方法依赖的package包/类
@Override
protected Object newEvent(LogDetails logDetails) {
final Message message = new SimpleMessage(logDetails.getLogMessage());
final StringMap contextData;
if (!logDetails.getMdc().isEmpty()) {
contextData = ContextDataFactory.createContextData();
logDetails.getMdc().entrySet().forEach(it -> contextData.putValue(it.getKey(), it.getValue()));
} else {
contextData = null;
}
Log4jLogEvent.Builder builder = Log4jLogEvent.newBuilder().setLoggerName(logDetails.getClassName())
.setTimeMillis(logDetails.getTimeMillis()).setLevel(Level.DEBUG).setContextData(contextData)
.setIncludeLocation(logDetails.isLocationInfo()).setLoggerFqcn(logDetails.getClassName()).setMessage(message);
if (logDetails.isLocationInfo()) {
builder.setSource(new StackTraceElement(logDetails.getClassName(), logDetails.getMethodName(),
logDetails.getFileName(), logDetails.getLineNumber()));
}
if (logDetails.getException() != null) {
builder.setThrown(logDetails.getException());
}
return builder.build();
}
示例2: initializeBuilder
import org.apache.logging.log4j.core.impl.Log4jLogEvent; //导入方法依赖的package包/类
/**
* Initializes the specified {@code Log4jLogEvent.Builder} from this {@code RingBufferLogEvent}.
* @param builder the builder whose fields to populate
*/
public void initializeBuilder(final Log4jLogEvent.Builder builder) {
builder.setContextData(contextData) //
.setContextStack(contextStack) //
.setEndOfBatch(endOfBatch) //
.setIncludeLocation(includeLocation) //
.setLevel(getLevel()) // ensure non-null
.setLoggerFqcn(fqcn) //
.setLoggerName(loggerName) //
.setMarker(marker) //
.setMessage(getNonNullImmutableMessage()) // ensure non-null & immutable
.setNanoTime(nanoTime) //
.setSource(location) //
.setThreadId(threadId) //
.setThreadName(threadName) //
.setThreadPriority(threadPriority) //
.setThrown(getThrown()) // may deserialize from thrownProxy
.setThrownProxy(thrownProxy) // avoid unnecessarily creating thrownProxy
.setInstant(instant) //
;
}