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


Java GelfTransports.valueOf方法代码示例

本文整理汇总了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);
}
 
开发者ID:tochkak,项目名称:play-graylog2,代码行数:23,代码来源:Graylog2Component.java

示例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);
    }
 
开发者ID:rkcpi,项目名称:logback-gelf-appender,代码行数:14,代码来源:GelfAppender.java

示例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);
    }
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-metrics-reporter,代码行数:9,代码来源:GelfTransportsConverter.java

示例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);
}
 
开发者ID:graylog-labs,项目名称:play2-graylog2,代码行数:41,代码来源:Graylog2Plugin.java

示例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);
}
 
开发者ID:joschi,项目名称:tinylog-gelf,代码行数:34,代码来源:GelfWriter.java


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