本文整理匯總了Java中net.logstash.logback.composite.JsonProviders類的典型用法代碼示例。如果您正苦於以下問題:Java JsonProviders類的具體用法?Java JsonProviders怎麽用?Java JsonProviders使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonProviders類屬於net.logstash.logback.composite包,在下文中一共展示了JsonProviders類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: overrideLogLevelProvider
import net.logstash.logback.composite.JsonProviders; //導入依賴的package包/類
@Test
public void overrideLogLevelProvider() {
SixtJsonEncoder encoder = new SixtJsonEncoder();
JsonProviders<ILoggingEvent> providers = encoder.getProviders();
int defaultCount = 0;
int overrideCount = 0;
for (JsonProvider<ILoggingEvent> provider : providers.getProviders()) {
if (provider instanceof LogLevelJsonProvider &&
!(provider instanceof CustomLogLevelJsonProvider)) {
defaultCount++;
} else if (provider instanceof CustomLogLevelJsonProvider) {
overrideCount++;
}
}
assertThat(defaultCount).isEqualTo(0);
assertThat(overrideCount).isEqualTo(1);
}
示例2: get
import net.logstash.logback.composite.JsonProviders; //導入依賴的package包/類
@Override
public LogstashLayout get() {
checkState(buildId.isPresent(), "buildId has not been set");
final LogstashLayout layout = new LogstashLayout();
/**
* Gradle doesn't include a complete SLF4J implementation, so when the provider tries to access MDC
* features a warning is output. So we need to expose a method to remove the provider.
*/
JsonProviders<ILoggingEvent> providers = layout.getProviders();
MdcJsonProvider provider = FluentIterable.from(providers.getProviders()).filter(MdcJsonProvider.class).first().get();
layout.getProviders().removeProvider(provider);
layout.setTimeZone("UTC");
layout.setCustomFields(String.format("{\"@source\":\"%s\"}", buildId.get()));
layout.start();
return layout;
}
示例3: setProviderItems
import net.logstash.logback.composite.JsonProviders; //導入依賴的package包/類
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public void setProviderItems(JsonProvider<ILoggingEvent> ... provs) {
JsonProviders<ILoggingEvent> provsContainer = this.getProviders();
Stream.of(provs).forEach(provsContainer::addProvider);
}