当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationException类代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.config.ConfigurationException的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationException类的具体用法?Java ConfigurationException怎么用?Java ConfigurationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurationException类属于org.apache.logging.log4j.core.config包,在下文中一共展示了ConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createInstance

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
/**
 * Creates an instance of {@link BatchEmitter} using one of available {@link BatchEmitterFactory} services. A check
 * for compatibility of given {@link ClientObjectFactory} with available services is performed.
 * <p>
 * NOTE: Currently the first found and compatible {@link BatchEmitterFactory} is selected as the {@link
 * BatchEmitter} provider. This is subject to change after new config features are added in future releases (
 * priority-based selection will be available to provide more flexible extension capabilities).
 *
 * @param batchSize           number of elements in a current batch that should trigger a delivery, regardless of
 *                            the delivery interval value
 * @param deliveryInterval    number of millis between two time-triggered deliveries, regardless of the batch size
 *                            value
 * @param clientObjectFactory client-specific objects provider
 * @param failoverPolicy      sink for failed batch items
 * @return T configured {@link BatchEmitter}
 */
public BatchEmitter createInstance(int batchSize,
                                   int deliveryInterval,
                                   ClientObjectFactory clientObjectFactory,
                                   FailoverPolicy failoverPolicy) {

    ServiceLoader<BatchEmitterFactory> loader = ServiceLoader.load(BatchEmitterFactory.class);
    Iterator<BatchEmitterFactory> it = loader.iterator();
    while (it.hasNext()) {
        BatchEmitterFactory factory = it.next();
        LOG.info("BatchEmitterFactory class found {}", factory);
        if (factory.accepts(clientObjectFactory.getClass())) {
            LOG.info("Using {} as BatchEmitterFactoryProvider", factory);
            return factory.createInstance(batchSize, deliveryInterval, clientObjectFactory, failoverPolicy);
        }
    }

    throw new ConfigurationException(String.format("No compatible BatchEmitter implementations for %s found", clientObjectFactory.getClass()));

}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:36,代码来源:BatchEmitterServiceProvider.java

示例2: loadClasspathResource

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
private String loadClasspathResource() {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(
                ClassLoader.getSystemClassLoader().getResourceAsStream(
                        path.replace(CLASSPATH_PREFIX, "")),
                "UTF-8"));
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
            sb.append('\n');
        }
        return sb.toString();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage(), e);
    }
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:18,代码来源:IndexTemplate.java

示例3: throwsExceptionOnUnresolvedAppender

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Test(expected = ConfigurationException.class)
public void throwsExceptionOnUnresolvedAppender() {

    // given
    Appender appender = mock(Appender.class);
    when(appender.isStarted()).thenReturn(true);
    Configuration configuration = mock(Configuration.class);
    String testAppenderRef = "testAppenderRef";
    when(configuration.getAppender(testAppenderRef)).thenReturn(null);

    FailoverPolicy<String> failoverPolicy = createTestFailoverPolicy(testAppenderRef, configuration);

    String failedMessage = "test failed message";

    // when
    failoverPolicy.deliver(failedMessage);

}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:19,代码来源:AppenderRefFailoverPolicyTest.java

示例4: createAppender

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
private AppenderComponentBuilder createAppender(final String key, final Properties properties) {
    final String name = (String) properties.remove(CONFIG_NAME);
    if (Strings.isEmpty(name)) {
        throw new ConfigurationException("No name attribute provided for Appender " + key);
    }
    final String type = (String) properties.remove(CONFIG_TYPE);
    if (Strings.isEmpty(type)) {
        throw new ConfigurationException("No type attribute provided for Appender " + key);
    }
    final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, type);
    addFiltersToComponent(appenderBuilder, properties);
    final Properties layoutProps = PropertiesUtil.extractSubset(properties, "layout");
    if (layoutProps.size() > 0) {
        appenderBuilder.add(createLayout(name, layoutProps));
    }

    return processRemainingProperties(appenderBuilder, properties);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:19,代码来源:PropertiesConfigurationBuilder.java

示例5: HttpURLConnectionManager

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
public HttpURLConnectionManager(final Configuration configuration, final LoggerContext loggerContext, final String name,
                                final URL url, final String method, final int connectTimeoutMillis,
                                final int readTimeoutMillis,
                                final Property[] headers,
                                final SslConfiguration sslConfiguration,
                                final boolean verifyHostname) {
    super(configuration, loggerContext, name);
    this.url = url;
    if (!(url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equalsIgnoreCase("https"))) {
        throw new ConfigurationException("URL must have scheme http or https");
    }
    this.isHttps = this.url.getProtocol().equalsIgnoreCase("https");
    this.method = Objects.requireNonNull(method, "method");
    this.connectTimeoutMillis = connectTimeoutMillis;
    this.readTimeoutMillis = readTimeoutMillis;
    this.headers = headers != null ? headers : new Property[0];
    this.sslConfiguration = sslConfiguration;
    if (this.sslConfiguration != null && !isHttps) {
        throw new ConfigurationException("SSL configuration can only be specified with URL scheme https");
    }
    this.verifyHostname = verifyHostname;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:23,代码来源:HttpURLConnectionManager.java

示例6: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public BulkProcessorObjectFactory build() {
    if (serverUris == null) {
        throw new ConfigurationException("No serverUris provided for JestClientConfig");
    }
    return new BulkProcessorObjectFactory(Arrays.asList(serverUris.split(";")));
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:8,代码来源:BulkProcessorObjectFactory.java

示例7: builderFailsIfServerUrisStringIsNull

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Test(expected = ConfigurationException.class)
public void builderFailsIfServerUrisStringIsNull() {

    // given
    Builder builder = createTestObjectFactoryBuilder();
    String serverUris = null;

    // when
    builder.withServerUris(serverUris);
    builder.build();

}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:13,代码来源:BulkProcessorObjectFactoryTest.java

示例8: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public JestHttpObjectFactory build() {
    if (serverUris == null) {
        throw new ConfigurationException("No serverUris provided for JestClientConfig");
    }
    return new JestHttpObjectFactory(Arrays.asList(serverUris.split(";")), connTimeout, readTimeout, maxTotalConnection, defaultMaxTotalConnectionPerRoute, discoveryEnabled);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:8,代码来源:JestHttpObjectFactory.java

示例9: add

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
/**
 * Transforms given items to client-specific model and adds them to provided {@link BatchEmitter}
 *
 * @param log batch item source
 *
 * @deprecated will use configured indexName for backwards compatibility
 */
@Override
public void add(String log) {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for AsyncBatchDelivery");
    }
    add(this.indexName, log);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:15,代码来源:AsyncBatchDelivery.java

示例10: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public AsyncBatchDelivery build() {
    if (indexName != null) {
        LOG.warn("AsyncBatchDelivery.indexName attribute has been deprecated and will be removed in 1.3. " +
                "It will NOT be used in AsyncBatchDelivery.add(String indexName,  T logObject) calls. " +
                "Please use IndexName instead.");
    }

    if (clientObjectFactory == null) {
        throw new ConfigurationException("No Elasticsearch client factory [JestHttp|ElasticsearchBulkProcessor] provided for AsyncBatchDelivery");
    }
    return new AsyncBatchDelivery(indexName, batchSize, deliveryInterval, clientObjectFactory, failoverPolicy, indexTemplate);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:14,代码来源:AsyncBatchDelivery.java

示例11: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public ElasticsearchAppender build() {
    if (name == null) {
        throw new ConfigurationException("No name provided for Elasticsearch appender");
    }
    if (batchDelivery == null) {
        throw new ConfigurationException("No batchDelivery [AsyncBatchDelivery] provided for Elasticsearch appender");
    }

    if (layout == null) {
        layout = JsonLayout.newBuilder().setCompact(true).build();
    }

    return new ElasticsearchAppender(name, filter, layout, ignoreExceptions, batchDelivery, messageOnly, indexNameFormatter);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:16,代码来源:ElasticsearchAppender.java

示例12: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public RollingIndexNameFormatter build() {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for RollingIndexName");
    }
    if (pattern == null) {
        throw new ConfigurationException("No pattern provided for RollingIndexName");
    }
    return new RollingIndexNameFormatter(indexName, pattern, getInitTimeInMillis(), TimeZone.getTimeZone(timeZone));
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:11,代码来源:RollingIndexNameFormatter.java

示例13: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public IndexTemplate build() {
    if (name == null) {
        throw new ConfigurationException("No name provided for IndexTemplate");
    }
    if ((path == null && source == null) || (path != null && source != null)) {
        throw new ConfigurationException("Either path or source have to be provided for IndexTemplate");
    }
    return new IndexTemplate(name, loadSource());
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:11,代码来源:IndexTemplate.java

示例14: loadFileSystemResource

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
private String loadFileSystemResource() {
    try {
        return new String(Files.readAllBytes(Paths.get(path)));
    } catch (IOException e){
        throw new ConfigurationException(e.getMessage(), e);
    }
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:8,代码来源:IndexTemplate.java

示例15: build

import org.apache.logging.log4j.core.config.ConfigurationException; //导入依赖的package包/类
@Override
public NoopIndexNameFormatter build() {
    if (indexName == null) {
        throw new ConfigurationException("No indexName provided for IndexName");
    }
    return new NoopIndexNameFormatter(indexName);
}
 
开发者ID:rfoltyns,项目名称:log4j2-elasticsearch,代码行数:8,代码来源:NoopIndexNameFormatter.java


注:本文中的org.apache.logging.log4j.core.config.ConfigurationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。