本文整理匯總了Java中net.logstash.logback.composite.JsonWritingUtils類的典型用法代碼示例。如果您正苦於以下問題:Java JsonWritingUtils類的具體用法?Java JsonWritingUtils怎麽用?Java JsonWritingUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonWritingUtils類屬於net.logstash.logback.composite包,在下文中一共展示了JsonWritingUtils類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeTo
import net.logstash.logback.composite.JsonWritingUtils; //導入依賴的package包/類
@Override
public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException {
String level;
switch (event.getLevel().toInt()) {
case Level.ERROR_INT:
level = "error";
break;
case Level.WARN_INT:
level = "warning";
break;
case Level.INFO_INT:
level = "info";
break;
case Level.DEBUG_INT:
level = "debug";
break;
case Level.TRACE_INT:
level = "trace";
break;
case Level.ALL_INT:
level = "all";
break;
case Level.OFF_INT:
level = "off";
break;
default:
level = "???";
}
JsonWritingUtils.writeStringField(
generator, getFieldName(), level);
}
示例2: writeTo
import net.logstash.logback.composite.JsonWritingUtils; //導入依賴的package包/類
@Override
public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException {
if (require) {
ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy();
AbstractLoggingException exception = AbstractLoggingException.getFromThrowableProxy(proxy);
if (exception != null) {
JsonWritingUtils.writeStringField(generator, getFieldName(), getValue(exception));
}
}
}
示例3: writeTo
import net.logstash.logback.composite.JsonWritingUtils; //導入依賴的package包/類
@Override
public void writeTo(JsonGenerator jsonGen, ILoggingEvent event) throws IOException {
Map<String, String> mdcProps = event.getMDCPropertyMap();
if (mdcProps.isEmpty()) {
return;
}
JsonWritingUtils.writeMapStringFields(jsonGen, this.getFieldName(),
mdcProps.entrySet().stream().filter(mdcPropEntry -> StringUtils.startsWith(mdcPropEntry.getKey(), SdcctPropertyNames.PREFIX)).collect(
SdcctStreamUtils.toMap(mdcPropEntry -> StringUtils.replaceChars(StringUtils.removeStart(mdcPropEntry.getKey(), SdcctPropertyNames.PREFIX),
SdcctStringUtils.PERIOD_CHAR, SdcctStringUtils.UNDERSCORE_CHAR), Entry::getValue, TreeMap::new)));
}
示例4: writeTo
import net.logstash.logback.composite.JsonWritingUtils; //導入依賴的package包/類
@Override
public void writeTo(JsonGenerator jsonGen, ILoggingEvent event) throws IOException {
MessageMarker msgMarker = SdcctStreamUtils.findInstance(SdcctMarkerUtils.stream(event.getMarker()), MessageMarker.class);
if (msgMarker != null) {
// noinspection ConstantConditions
JsonWritingUtils.writeStringField(jsonGen, this.getFieldName(), msgMarker.getMessages().get(AppenderType.LOGSTASH_FILE));
} else {
super.writeTo(jsonGen, event);
}
}