本文整理汇总了Java中org.graylog2.gelfclient.GelfTransports.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java GelfTransports.valueOf方法的具体用法?Java GelfTransports.valueOf怎么用?Java GelfTransports.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graylog2.gelfclient.GelfTransports
的用法示例。
在下文中一共展示了GelfTransports.valueOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGelfConfiguration
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
private GelfConfiguration getGelfConfiguration(Configuration config) {
final Integer queueCapacity = config.getInt("graylog2.appender.queue-size", 512);
final Long reconnectInterval = config.getMilliseconds("graylog2.appender.reconnect-interval", 500L);
final Long connectTimeout = config.getMilliseconds("graylog2.appender.connect-timeout", 1000L);
final Boolean isTcpNoDelay = config.getBoolean("graylog2.appender.tcp-nodelay", false);
final String hostString = config.getString("graylog2.appender.host", "127.0.0.1:12201");
final String protocol = config.getString("graylog2.appender.protocol", "udp");
final HostAndPort hostAndPort = HostAndPort.fromString(hostString);
GelfTransports gelfTransport = GelfTransports.valueOf(protocol.toUpperCase());
final Integer sendBufferSize = config.getInt("graylog2.appender.sendbuffersize", 0); // causes the socket default to be used
return new GelfConfiguration(hostAndPort.getHost(), hostAndPort.getPort())
.transport(gelfTransport)
.reconnectDelay(reconnectInterval.intValue())
.queueSize(queueCapacity)
.connectTimeout(connectTimeout.intValue())
.tcpNoDelay(isTcpNoDelay)
.sendBufferSize(sendBufferSize);
}
示例2: getGelfConfiguration
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
private GelfConfiguration getGelfConfiguration() {
final InetSocketAddress serverAddress = new InetSocketAddress(server, port);
final GelfTransports gelfProtocol = GelfTransports.valueOf(protocol().toUpperCase());
return new GelfConfiguration(serverAddress).transport(gelfProtocol)
.queueSize(queueSize)
.connectTimeout(connectTimeout)
.reconnectDelay(reconnectDelay)
.sendBufferSize(sendBufferSize)
.tcpNoDelay(tcpNoDelay)
.tcpKeepAlive(tcpKeepAlive);
}
示例3: convertFrom
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
@Override
public GelfTransports convertFrom(String value) {
try {
return GelfTransports.valueOf(Strings.nullToEmpty(value).toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException e) {
throw new ParameterException("Couldn't convert value \"" + value + "\" to GELF transport.", e);
}
}
示例4: Graylog2Plugin
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
public Graylog2Plugin(Application app) {
final Configuration config = app.configuration();
accessLogEnabled = config.getBoolean("graylog2.appender.send-access-log", false);
queueCapacity = config.getInt("graylog2.appender.queue-size", 512);
reconnectInterval = config.getMilliseconds("graylog2.appender.reconnect-interval", 500L);
connectTimeout = config.getMilliseconds("graylog2.appender.connect-timeout", 1000L);
isTcpNoDelay = config.getBoolean("graylog2.appender.tcp-nodelay", false);
sendBufferSize = config.getInt("graylog2.appender.sendbuffersize", 0); // causes the socket default to be used
try {
canonicalHostName = config.getString("graylog2.appender.sourcehost", InetAddress.getLocalHost().getCanonicalHostName());
} catch (UnknownHostException e) {
canonicalHostName = "localhost";
log.error("Unable to resolve canonical localhost name. " +
"Please set it manually via graylog2.appender.sourcehost or fix your lookup service, falling back to {}", canonicalHostName);
}
// TODO make this a list and dynamically accessible from the application
final String hostString = config.getString("graylog2.appender.host", "127.0.0.1:12201");
final String protocol = config.getString("graylog2.appender.protocol", "tcp");
final HostAndPort hostAndPort = HostAndPort.fromString(hostString);
final GelfTransports gelfTransport = GelfTransports.valueOf(protocol.toUpperCase());
final GelfConfiguration gelfConfiguration = new GelfConfiguration(hostAndPort.getHostText(), hostAndPort.getPort())
.transport(gelfTransport)
.reconnectDelay(reconnectInterval.intValue())
.queueSize(queueCapacity)
.connectTimeout(connectTimeout.intValue())
.tcpNoDelay(isTcpNoDelay)
.sendBufferSize(sendBufferSize);
this.transport = GelfTransports.create(gelfConfiguration);
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
gelfAppender = new GelfclientAppender(transport, getLocalHostName());
gelfAppender.setContext(lc);
}
示例5: GelfWriter
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
/**
* Construct a new GelfWriter instance.
*
* @param server the hostname of the GELF-compatible server
* @param port the port of the GELF-compatible server
* @param transport the transport protocol to use
* @param hostname the hostname of the application
* @param additionalLogEntryValues additional information for log messages, see {@link LogEntryValue}
* @param staticFields a list of additional static fields for the GELF messages (key-value-delimiter
* is ':')
* @param queueSize the size of the internal queue the GELF client is using
* @param connectTimeout the connection timeout for TCP connections in milliseconds
* @param reconnectDelay the time to wait between reconnects in milliseconds
* @param sendBufferSize the size of the socket send buffer in bytes; a value of {@code -1}
* deactivates the socket send buffer.
* @param tcpNoDelay {@code true} if Nagle's algorithm should used for TCP connections,
* {@code false} otherwise
*/
public GelfWriter(final String server,
final int port,
final String transport,
final String hostname,
final String[] additionalLogEntryValues,
final String[] staticFields,
final int queueSize,
final int connectTimeout,
final int reconnectDelay,
final int sendBufferSize,
final boolean tcpNoDelay) {
this(server, port, GelfTransports.valueOf(transport), hostname,
buildLogEntryValuesFromString(additionalLogEntryValues), buildStaticFields(staticFields),
queueSize, connectTimeout, reconnectDelay, sendBufferSize, tcpNoDelay);
}