本文整理汇总了Java中org.graylog2.gelfclient.GelfTransports.create方法的典型用法代码示例。如果您正苦于以下问题:Java GelfTransports.create方法的具体用法?Java GelfTransports.create怎么用?Java GelfTransports.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graylog2.gelfclient.GelfTransports
的用法示例。
在下文中一共展示了GelfTransports.create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void init(Configuration configuration) throws Exception {
final InetSocketAddress remoteAddress = new InetSocketAddress(server, port);
final GelfConfiguration gelfConfiguration = new GelfConfiguration(remoteAddress)
.transport(transport)
.queueSize(queueSize)
.connectTimeout(connectTimeout)
.reconnectDelay(reconnectDelay)
.sendBufferSize(sendBufferSize)
.tcpNoDelay(tcpNoDelay);
client = GelfTransports.create(gelfConfiguration);
VMShutdownHook.register(this);
}
示例2: doStart
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
@Override
protected void doStart() {
final GelfConfiguration clientConfig = new GelfConfiguration(configuration.getHost(), configuration.getPort());
switch (configuration.getProtocol()) {
case UDP:
clientConfig
.transport(GelfTransports.UDP)
.queueSize(configuration.getClientQueueSize())
.sendBufferSize(configuration.getClientSendBufferSize());
case TCP:
clientConfig
.transport(GelfTransports.TCP)
.queueSize(configuration.getClientQueueSize())
.connectTimeout(configuration.getClientConnectTimeout())
.reconnectDelay(configuration.getClientReconnectDelay())
.tcpNoDelay(configuration.isClientTcpNoDelay())
.sendBufferSize(configuration.getClientSendBufferSize());
if (configuration.isClientTls()) {
clientConfig.enableTls();
clientConfig.tlsTrustCertChainFile(configuration.getClientTlsCertChainFile());
if (configuration.isClientTlsVerifyCert()) {
clientConfig.enableTlsCertVerification();
} else {
clientConfig.disableTlsCertVerification();
}
}
break;
}
LOG.info("Starting GELF transport: {}", clientConfig);
this.transport = GelfTransports.create(clientConfig);
transportInitialized.countDown();
notifyStarted();
}
示例3: Graylog2Impl
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
@Inject
public Graylog2Impl(Configuration config) {
String canonicalHostName;
try {
canonicalHostName = config.getString(
"graylog2.appender.sourcehost",
InetAddress.getLocalHost().getCanonicalHostName()
);
} catch (UnknownHostException e) {
canonicalHostName = "unknown";
}
accessLogEnabled = config.getBoolean("graylog2.appender.access-log", false);
final GelfConfiguration gelfConfiguration = getGelfConfiguration(config);
GelfTransport transport = GelfTransports.create(gelfConfiguration);
final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
final Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
gelfClientAppender = new GelfClientAppender(transport, canonicalHostName);
gelfClientAppender.setContext(lc);
gelfClientAppender.start();
rootLogger.addAppender(gelfClientAppender);
}
示例4: GraylogUplink
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
public GraylogUplink(String hostname, int port, String nzymeId, String networkInterfaceName) {
this.nzymeId = nzymeId;
this.networkInterfaceName = networkInterfaceName;
this.gelfTransport = GelfTransports.create(new GelfConfiguration(new InetSocketAddress(hostname, port))
.transport(GelfTransports.TCP)
.queueSize(512)
.connectTimeout(5000)
.reconnectDelay(1000)
.tcpNoDelay(true)
.sendBufferSize(32768));
}
示例5: 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);
}
示例6: start
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
@Override
public void start() {
super.start();
client = GelfTransports.create(gelfConfiguration);
}
示例7: createGelfClient
import org.graylog2.gelfclient.GelfTransports; //导入方法依赖的package包/类
private void createGelfClient() {
client = GelfTransports.create(getGelfConfiguration());
}