本文整理汇总了Java中org.apache.logging.log4j.core.config.ConfigurationSource.getInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSource.getInputStream方法的具体用法?Java ConfigurationSource.getInputStream怎么用?Java ConfigurationSource.getInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.config.ConfigurationSource
的用法示例。
在下文中一共展示了ConfigurationSource.getInputStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConfiguration
import org.apache.logging.log4j.core.config.ConfigurationSource; //导入方法依赖的package包/类
@Override
public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
final ConfigurationBuilder<BuiltConfiguration> builder;
try (final InputStream configStream = source.getInputStream()) {
builder = new Log4j1ConfigurationParser().buildConfigurationBuilder(configStream);
} catch (final IOException e) {
throw new ConfigurationException("Unable to load " + source, e);
}
return builder.build();
}
示例2: getConfiguration
import org.apache.logging.log4j.core.config.ConfigurationSource; //导入方法依赖的package包/类
@Override
public PropertiesConfiguration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
final Properties properties = new Properties();
try (final InputStream configStream = source.getInputStream()) {
properties.load(configStream);
} catch (final IOException ioe) {
throw new ConfigurationException("Unable to load " + source.toString(), ioe);
}
return new PropertiesConfigurationBuilder()
.setConfigurationSource(source)
.setRootProperties(properties)
.setLoggerContext(loggerContext)
.build();
}
示例3: createAdvertiser
import org.apache.logging.log4j.core.config.ConfigurationSource; //导入方法依赖的package包/类
public void createAdvertiser(final String advertiserString, final ConfigurationSource configSource) {
byte[] buffer = null;
try {
if (configSource != null) {
final InputStream is = configSource.getInputStream();
if (is != null) {
buffer = toByteArray(is);
}
}
} catch (final IOException ioe) {
LOGGER.warn("Unable to read configuration source " + configSource.toString());
}
super.createAdvertiser(advertiserString, configSource, buffer, contentType);
}
示例4: JsonConfiguration
import org.apache.logging.log4j.core.config.ConfigurationSource; //导入方法依赖的package包/类
public JsonConfiguration(final LoggerContext loggerContext, final ConfigurationSource configSource) {
super(loggerContext, configSource);
final File configFile = configSource.getFile();
byte[] buffer;
try {
try (final InputStream configStream = configSource.getInputStream()) {
buffer = toByteArray(configStream);
}
final InputStream is = new ByteArrayInputStream(buffer);
root = getObjectMapper().readTree(is);
if (root.size() == 1) {
for (final JsonNode node : root) {
root = node;
}
}
processAttributes(rootNode, root);
final StatusConfiguration statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES)
.withStatus(getDefaultStatus());
for (final Map.Entry<String, String> entry : rootNode.getAttributes().entrySet()) {
final String key = entry.getKey();
final String value = getStrSubstitutor().replace(entry.getValue());
// TODO: this duplicates a lot of the XmlConfiguration constructor
if ("status".equalsIgnoreCase(key)) {
statusConfig.withStatus(value);
} else if ("dest".equalsIgnoreCase(key)) {
statusConfig.withDestination(value);
} else if ("shutdownHook".equalsIgnoreCase(key)) {
isShutdownHookEnabled = !"disable".equalsIgnoreCase(value);
} else if ("shutdownTimeout".equalsIgnoreCase(key)) {
shutdownTimeoutMillis = Long.parseLong(value);
} else if ("verbose".equalsIgnoreCase(entry.getKey())) {
statusConfig.withVerbosity(value);
} else if ("packages".equalsIgnoreCase(key)) {
pluginPackages.addAll(Arrays.asList(value.split(Patterns.COMMA_SEPARATOR)));
} else if ("name".equalsIgnoreCase(key)) {
setName(value);
} else if ("monitorInterval".equalsIgnoreCase(key)) {
final int intervalSeconds = Integer.parseInt(value);
if (intervalSeconds > 0) {
getWatchManager().setIntervalSeconds(intervalSeconds);
if (configFile != null) {
final FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners);
getWatchManager().watchFile(configFile, watcher);
}
}
} else if ("advertiser".equalsIgnoreCase(key)) {
createAdvertiser(value, configSource, buffer, "application/json");
}
}
statusConfig.initialize();
if (getName() == null) {
setName(configSource.getLocation());
}
} catch (final Exception ex) {
LOGGER.error("Error parsing " + configSource.getLocation(), ex);
}
}