本文整理汇总了Java中ch.qos.logback.classic.spi.LoggingEvent.setArgumentArray方法的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent.setArgumentArray方法的具体用法?Java LoggingEvent.setArgumentArray怎么用?Java LoggingEvent.setArgumentArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.spi.LoggingEvent
的用法示例。
在下文中一共展示了LoggingEvent.setArgumentArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public LoggingEvent build(int i) {
LoggingEvent le = new LoggingEvent();
le.setTimeStamp(System.currentTimeMillis());
Object[] aa = new Object[] { i, "HELLO WORLD [========== ]" + i };
le.setArgumentArray(aa);
String msg = MSG + i;
le.setMessage(msg);
// compute formatted message
// this forces le.formmatedMessage to be set (this is the whole point of the
// exercise)
le.getFormattedMessage();
le.setLevel(Level.DEBUG);
le.setLoggerName(logger.getName());
le.setLoggerContextRemoteView(loggerContext.getLoggerContextRemoteView());
le.setThreadName("threadName");
return le;
}
示例2: createLoggingEvent
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private LoggingEvent createLoggingEvent(final Level level,
final String message,
final Object... params) {
final LoggingEvent loggingEvent = new LoggingEvent();
loggingEvent.setMDCPropertyMap(singletonMap("job_id", "someJobId"));
loggingEvent.setMessage(message);
loggingEvent.setArgumentArray(params);
loggingEvent.setLevel(level);
loggingEvent.setMarker(JobMarker.JOB);
return loggingEvent;
}
示例3: append
import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected void append(ILoggingEvent event) {
if (event == null) {
return;
}
// create a copy of the logging event to avoid passing exception stacktraces to GELF's short_message field
LoggingEvent copy = new LoggingEvent();
copy.setMessage(event.getMessage());
copy.setLevel(event.getLevel());
copy.setArgumentArray(event.getArgumentArray());
final GelfMessageBuilder builder = new GelfMessageBuilder(this.layout.doLayout(copy), hostName()).timestamp(
event.getTimeStamp() / 1000d)
.level(GelfMessageLevel.fromNumericLevel(toGelfNumericValue(event.getLevel())))
.additionalField("loggerName", event.getLoggerName())
.additionalField("threadName", event.getThreadName());
final Marker marker = event.getMarker();
if (marker != null) {
builder.additionalField("marker", marker.getName());
}
if (includeMDC) {
for (Map.Entry<String, String> entry : event.getMDCPropertyMap().entrySet()) {
builder.additionalField(entry.getKey(), entry.getValue());
}
}
StackTraceElement[] callerData = event.getCallerData();
if (includeSource && event.hasCallerData() && callerData.length > 0) {
StackTraceElement source = callerData[0];
builder.additionalField("sourceFileName", source.getFileName());
builder.additionalField("sourceMethodName", source.getMethodName());
builder.additionalField("sourceClassName", source.getClassName());
builder.additionalField("sourceLineNumber", source.getLineNumber());
}
IThrowableProxy thrown = event.getThrowableProxy();
if (includeStackTrace && thrown != null) {
String convertedThrowable = throwableConverter.convert(event);
builder.additionalField("exceptionClass", thrown.getClassName());
builder.additionalField("exceptionMessage", thrown.getMessage());
builder.additionalField("exceptionStackTrace", convertedThrowable);
builder.fullMessage(event.getFormattedMessage() + "\n\n" + convertedThrowable);
} else {
builder.fullMessage(event.getFormattedMessage());
}
if (includeLevelName) {
builder.additionalField("levelName", event.getLevel().levelStr);
}
if (!additionalFields.isEmpty()) {
builder.additionalFields(additionalFields);
}
if(!client.trySend(builder.build())) {
addError("Failed to write log event to the GELF server using trySend");
}
}