本文整理汇总了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);
}