• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GelfMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: append

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
public void append(
        String shortMessage, AccessLogMessage accessLogMessage,
        Map<String, Object> additionalFields) {

    GelfMessage gelfMessage = new GelfMessageBuilder(shortMessage, hostname)
            .additionalFields(accessLogMessage.getFields())
            .additionalFields(additionalFields)
            .level(GelfMessageLevel.INFO)
            .build();
    try {
        transport.send(gelfMessage);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

}
 
开发者ID:tochkak,项目名称:play-graylog2,代码行数:17,代码来源:GelfClientAppender.java


示例2: shouldNotAddExceptionToFullMessage

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldNotAddExceptionToFullMessage() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(true, true);
    final LogEvent event = createLogEventMock();
    given(event.getThrown()).willReturn(new RuntimeException("Outer Exception", new Exception("Inner Exception")));

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final String fullMessage = gelfMessageCaptor.getValue().getFullMessage();
    assertThat(fullMessage, is("Some Message"));
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:17,代码来源:GelfAppenderThrowableTest.java


示例3: shouldAppendExceptionClassAndMessage

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldAppendExceptionClassAndMessage() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(true, true);
    final LogEvent event = createLogEventMock();
    given(event.getThrown()).willReturn(new RuntimeException("Outer Exception", new Exception("Inner Exception")));

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final Object exceptionMessage = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionMessage");
    final Object exceptionClass = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionClass");
    assertThat(exceptionMessage, notNullValue());
    assertThat(exceptionMessage.toString(), containsString("Outer Exception"));
    assertThat(exceptionClass, notNullValue());
    assertThat(exceptionClass.toString(), containsString("java.lang.RuntimeException"));
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:25,代码来源:GelfAppenderThrowableTest.java


示例4: shouldNotAppendExceptionInformationIfNotRequested

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldNotAppendExceptionInformationIfNotRequested() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(false, false);
    final LogEvent event = createLogEventMock();
    given(event.getThrown()).willReturn(new RuntimeException("Outer Exception", new Exception("Inner Exception")));

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final Object exceptionMessage = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionMessage");
    final Object exceptionClass = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionClass");
    final Object exceptionStackTrace = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionStackTrace");
    assertThat(exceptionMessage, nullValue());
    assertThat(exceptionClass, nullValue());
    assertThat(exceptionStackTrace, nullValue());
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:27,代码来源:GelfAppenderThrowableTest.java


示例5: shouldNotFailIfNoExceptionAvailable

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldNotFailIfNoExceptionAvailable() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(false, false);
    final LogEvent event = createLogEventMock();
    given(event.getThrown()).willReturn(null);

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final Object exceptionMessage = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionMessage");
    final Object exceptionClass = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionClass");
    final Object exceptionStackTrace = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionStackTrace");
    assertThat(exceptionMessage, nullValue());
    assertThat(exceptionClass, nullValue());
    assertThat(exceptionStackTrace, nullValue());
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:27,代码来源:GelfAppenderThrowableTest.java


示例6: shouldAppendStacktraceWithCauses

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldAppendStacktraceWithCauses() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(true, true);
    final LogEvent event = createLogEventMock();
    given(event.getThrown()).willReturn(new RuntimeException("Outer Exception", new Exception("Inner Exception")));

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final Object exceptionStackTrace = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionStackTrace");
    assertThat(exceptionStackTrace, notNullValue());
    assertThat(exceptionStackTrace.toString(), containsString("Caused by: java.lang.Exception: Inner Exception"));
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:20,代码来源:GelfAppenderThrowableTest.java


示例7: shouldAppendStacktraceWithoutCauses

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void shouldAppendStacktraceWithoutCauses() throws InterruptedException {
    // given
    final GelfAppender gelfAppender = createGelfAppender(true, false);
    final LogEvent event = createLogEventMock();
    final RuntimeException exception = new RuntimeException("Outer Exception", new Exception("Inner Exception"));
    given(event.getThrown()).willReturn(exception);

    // when
    gelfAppender.append(event);

    // then
    ArgumentCaptor<GelfMessage> gelfMessageCaptor = ArgumentCaptor.forClass(GelfMessage.class);
    verify(mockedGelfTransport).trySend(gelfMessageCaptor.capture());
    final Object exceptionStackTrace = gelfMessageCaptor.getValue()
            .getAdditionalFields()
            .get("exceptionStackTrace");
    assertThat(exceptionStackTrace, notNullValue());

    assertThat(exceptionStackTrace.toString(), is(gelfAppender.getSimpleStacktraceAsString(exception)));
    assertThat(exceptionStackTrace.toString(), not(containsString("Caused by: java.lang.Exception: Inner Exception")));
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:23,代码来源:GelfAppenderThrowableTest.java


示例8: convertToGelfMessage

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
private GelfMessage convertToGelfMessage(ILoggingEvent event) {
    return new GelfMessageBuilder(event.getFormattedMessage(), hostname)
            .timestamp(event.getTimeStamp() / 1000d)
            .level(toGelfMessageLevel(event.getLevel()))
            .additionalField("threadname", event.getThreadName())
            .additionalField("logger", event.getLoggerName())
            .build();
}
 
开发者ID:tochkak,项目名称:play-graylog2,代码行数:9,代码来源:GelfClientAppender.java


示例9: notify

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Override
public void notify(Notification notification, @Nullable Dot11MetaInformation meta) {
    // Add signal strength and frequency to message.
    StringBuilder sb = new StringBuilder(notification.getMessage());

    if(meta != null) {
        sb.append(" ").append("(").append(meta.getFrequency()).append("MHz @")
                .append(" ").append(meta.getAntennaSignal()).append("dBm)")
                .toString();
    }

    GelfMessage gelf = new GelfMessage(sb.toString(), SOURCE);
    gelf.addAdditionalFields(notification.getAdditionalFields());
    gelf.addAdditionalField("nzyme_sensor_id", this.nzymeId);
    gelf.addAdditionalField("nic_name", this.networkInterfaceName);

    // Meta information.
    if(meta != null) {
        gelf.addAdditionalField("signal_strength", meta.getAntennaSignal());
        gelf.addAdditionalField("frequency", meta.getFrequency());
        gelf.addAdditionalField("signal_quality", calculateSignalQuality(meta.getAntennaSignal()));
        gelf.addAdditionalField("is_wep", meta.isWep());

        if(meta.getMacTimestamp() >= 0) {
            gelf.addAdditionalField("mac_timestamp", meta.getMacTimestamp());
        }
    }

    this.gelfTransport.trySend(gelf);
}
 
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:31,代码来源:GraylogUplink.java


示例10: toJson

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
private byte[] toJson(final GelfMessage message) throws Exception {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();

    try (final JsonGenerator jg = jsonFactory.createGenerator(out, JsonEncoding.UTF8)) {
        jg.writeStartObject();

        jg.writeStringField("version", message.getVersion().toString());
        jg.writeNumberField("timestamp", message.getTimestamp());
        jg.writeStringField("host", message.getHost());
        jg.writeStringField("short_message", message.getMessage());
        if (message.getLevel() != null) {
            jg.writeNumberField("level", message.getLevel().getNumericLevel());
        }

        if(null != message.getFullMessage()) {
            jg.writeStringField("full_message", message.getFullMessage());
        }

        for (Map.Entry<String, Object> field : message.getAdditionalFields().entrySet()) {
            final String realKey = field.getKey().startsWith("_") ? field.getKey() : ("_" + field.getKey());

            if (field.getValue() instanceof Number) {
                // Let Jackson figure out how to write Number values.
                jg.writeObjectField(realKey, field.getValue());
            } else if (field.getValue() == null) {
                jg.writeNullField(realKey);
            } else {
                jg.writeStringField(realKey, field.getValue().toString());
            }
        }

        jg.writeEndObject();
    }

    return out.toByteArray();
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:37,代码来源:GelfMessageJsonEncoder.java


示例11: AbstractGelfTransport

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
/**
 * Creates a new GELF transport with the given configuration and {@link java.util.concurrent.BlockingQueue}.
 *
 * @param config the client configuration
 * @param queue  the {@link BlockingQueue} used to buffer GELF messages
 */
public AbstractGelfTransport(final GelfConfiguration config, final BlockingQueue<GelfMessage> queue) {
    this.config = config;
    this.queue = queue;
    this.workerGroup = new NioEventLoopGroup(config.getThreads(), new DefaultThreadFactory(getClass(), true));
    createBootstrap(workerGroup);
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:13,代码来源:AbstractGelfTransport.java


示例12: testExceptionIsPassedThrough

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test(expectedExceptions = EncoderException.class)
public void testExceptionIsPassedThrough() throws Exception {
    final JsonFactory jsonFactory = mock(JsonFactory.class);
    when(jsonFactory.createGenerator(any(OutputStream.class), eq(JsonEncoding.UTF8))).thenThrow(new IOException());

    final EmbeddedChannel channel = new EmbeddedChannel(new GelfMessageJsonEncoder(jsonFactory));
    assertTrue(channel.writeOutbound(new GelfMessage("test")));
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:9,代码来源:GelfMessageJsonEncoderTest.java


示例13: testNullValue

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void testNullValue() throws Exception {
    channel = new EmbeddedChannel(new GelfMessageJsonEncoder());
    message = new GelfMessage("test");
    message.addAdditionalField("_null", null);

    assertTrue(channel.writeOutbound(message));
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:9,代码来源:GelfMessageJsonEncoderTest.java


示例14: append

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
public void append(GelfMessage gelfMessage) {
    try {
        transport.send(gelfMessage);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
开发者ID:graylog-labs,项目名称:play2-graylog2,代码行数:8,代码来源:GelfclientAppender.java


示例15: encode

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void encode(ChannelHandlerContext ctx, GelfMessage message, List<Object> out) throws Exception {
    out.add(Unpooled.wrappedBuffer(toJson(message)));
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:8,代码来源:GelfMessageJsonEncoder.java


示例16: GelfSenderThread

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
/**
 * Creates a new sender thread with the given {@link BlockingQueue} as source of messages.
 *
 * @param queue the {@link BlockingQueue} used as source of {@link GelfMessage}s
 * @param maxInflightSends the maximum number of outstanding network writes/flushes before the sender spins
 */
public GelfSenderThread(final BlockingQueue<GelfMessage> queue, int maxInflightSends) {
    this.maxInflightSends = maxInflightSends;
    this.lock = new ReentrantLock();
    this.connectedCond = lock.newCondition();

    if (maxInflightSends <= 0) {
        throw new IllegalArgumentException("maxInflightSends must be larger than 0");
    }

    this.senderThread = new Thread(new Runnable() {
        @Override
        public void run() {
            GelfMessage gelfMessage = null;
            final AtomicInteger inflightSends = new AtomicInteger(0);
            final ChannelFutureListener inflightListener = new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    inflightSends.decrementAndGet();
                }
            };

            while (keepRunning.get()) {
                // wait until we are connected to the graylog2 server before polling log events from the queue
                lock.lock();
                try {
                    while (channel == null || !channel.isActive()) {
                        try {
                            connectedCond.await();
                        } catch (InterruptedException e) {
                            if (!keepRunning.get()) {
                                // bail out if we are awoken because the application is stopping
                                break;
                            }
                        }
                    }
                    // we are connected, let's start sending logs
                    try {
                        // if we have a lingering event already, try to send that instead of polling a new one.
                        if (gelfMessage == null) {
                            gelfMessage = queue.poll(100, TimeUnit.MILLISECONDS);
                        }
                        // if we are still connected, convert LoggingEvent to GELF and send it
                        // but if we aren't connected anymore, we'll have already pulled an event from the queue,
                        // which we keep hanging around in this thread and in the next loop iteration will block until we are connected again.
                        if (gelfMessage != null && channel != null && channel.isActive()) {
                            // Do not allow more than "maxInflightSends" concurrent writes in netty, to avoid having netty buffer
                            // excessively when faced with slower consumers
                            while (inflightSends.get() > GelfSenderThread.this.maxInflightSends) {
                                Uninterruptibles.sleepUninterruptibly(1, MICROSECONDS);
                            }
                            inflightSends.incrementAndGet();

                            // Write the GELF message to the pipeline. The protocol specific channel handler
                            // will take care of encoding.
                            channel.writeAndFlush(gelfMessage).addListener(inflightListener);
                            gelfMessage = null;
                        }
                    } catch (InterruptedException e) {
                        // ignore, when stopping keepRunning will be set to false outside
                    }
                } finally {
                    lock.unlock();
                }
            }

            LOG.debug("GelfSenderThread exiting!");
        }
    });

    this.senderThread.setDaemon(true);
    this.senderThread.setName("GelfSenderThread-" + senderThread.getId());
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:79,代码来源:GelfSenderThread.java


示例17: testOptionalFullMessage

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void testOptionalFullMessage() throws Exception {
    final EmbeddedChannel channel = new EmbeddedChannel(new GelfMessageJsonEncoder());
    final GelfMessage message = new GelfMessageBuilder("test").build();
    assertTrue(channel.writeOutbound(message));
    assertTrue(channel.finish());

    final ByteBuf byteBuf = (ByteBuf) channel.readOutbound();
    final byte[] bytes = new byte[byteBuf.readableBytes()];
    byteBuf.getBytes(0, bytes).release();
    final JsonFactory json = new JsonFactory();
    final JsonParser parser = json.createParser(bytes);

    String version = null;
    Number timestamp = null;
    String host = null;
    String short_message = null;
    String full_message = null;
    Number level = null;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        String key = parser.getCurrentName();

        if (key == null) {
            continue;
        }

        parser.nextToken();

        switch (key) {
            case "version":
                version = parser.getText();
                break;
            case "timestamp":
                timestamp = parser.getNumberValue();
                break;
            case "host":
                host = parser.getText();
                break;
            case "short_message":
                short_message = parser.getText();
                break;
            case "full_message":
                full_message = parser.getText();
                break;
            case "level":
                level = parser.getNumberValue();
                break;
            default:
                throw new Exception("Found unexpected field in JSON payload: " + key);
        }
    }

    assertEquals(message.getVersion().toString(), version);
    assertEquals(message.getTimestamp(), timestamp);
    assertEquals(message.getHost(), host);
    assertEquals(message.getMessage(), short_message);
    assertNull(full_message);
    assertEquals(message.getLevel().getNumericLevel(), level);
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:61,代码来源:GelfMessageJsonEncoderTest.java


示例18: testNullLevel

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Test
public void testNullLevel() throws Exception {
    final EmbeddedChannel channel = new EmbeddedChannel(new GelfMessageJsonEncoder());
    final GelfMessage message = new GelfMessageBuilder("test").build();

    message.setLevel(null);

    assertTrue(channel.writeOutbound(message));
    assertTrue(channel.finish());

    final ByteBuf byteBuf = (ByteBuf) channel.readOutbound();
    final byte[] bytes = new byte[byteBuf.readableBytes()];
    byteBuf.getBytes(0, bytes).release();
    final JsonFactory json = new JsonFactory();
    final JsonParser parser = json.createParser(bytes);

    String version = null;
    Number timestamp = null;
    String host = null;
    String short_message = null;
    String full_message = null;
    Number level = null;

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        String key = parser.getCurrentName();

        if (key == null) {
            continue;
        }

        parser.nextToken();

        switch (key) {
            case "version":
                version = parser.getText();
                break;
            case "timestamp":
                timestamp = parser.getNumberValue();
                break;
            case "host":
                host = parser.getText();
                break;
            case "short_message":
                short_message = parser.getText();
                break;
            case "full_message":
                full_message = parser.getText();
                break;
            case "level":
                level = parser.getNumberValue();
                break;
            default:
                throw new Exception("Found unexpected field in JSON payload: " + key);
        }
    }

    assertEquals(message.getVersion().toString(), version);
    assertEquals(message.getTimestamp(), timestamp);
    assertEquals(message.getHost(), host);
    assertEquals(message.getMessage(), short_message);
    assertNull(full_message);
    assertNull(level);
}
 
开发者ID:Graylog2,项目名称:gelfclient,代码行数:64,代码来源:GelfMessageJsonEncoderTest.java


示例19: append

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Override
public void append(LogEvent event) {
    final Layout<? extends Serializable> layout = getLayout();
    final String formattedMessage;
    if (layout == null) {
        formattedMessage = event.getMessage().getFormattedMessage();
    } else {
        formattedMessage = new String(layout.toByteArray(event), StandardCharsets.UTF_8);
    }

    final GelfMessageBuilder builder = new GelfMessageBuilder(formattedMessage, hostName)
            .timestamp(event.getTimeMillis() / 1000d)
            .level(GelfMessageLevel.fromNumericLevel(Severity.getSeverity(event.getLevel()).getCode()))
            .additionalField("loggerName", event.getLoggerName())
            .additionalField("threadName", event.getThreadName());

    final Marker marker = event.getMarker();
    if (marker != null) {
        builder.additionalField("marker", marker.getName());
    }

    if (includeThreadContext) {
        for (Map.Entry<String, String> entry : event.getContextMap().entrySet()) {
            builder.additionalField(entry.getKey(), entry.getValue());
        }

        // Guard against https://issues.apache.org/jira/browse/LOG4J2-1530
        final ThreadContext.ContextStack contextStack = event.getContextStack();
        if (contextStack != null) {
            final List<String> contextStackItems = contextStack.asList();
            if (contextStackItems != null && !contextStackItems.isEmpty()) {
                builder.additionalField("contextStack", contextStackItems.toString());
            }
        }
    }

    if (includeSource) {
        final StackTraceElement source = event.getSource();
        if (source != null) {
            builder.additionalField("sourceFileName", source.getFileName());
            builder.additionalField("sourceMethodName", source.getMethodName());
            builder.additionalField("sourceClassName", source.getClassName());
            builder.additionalField("sourceLineNumber", source.getLineNumber());
        }
    }

    @SuppressWarnings("all")
    final Throwable thrown = event.getThrown();
    if (includeStackTrace && thrown != null) {
        String stackTrace;
        if (includeExceptionCause) {
            final StringWriter stringWriter = new StringWriter();
            final PrintWriter printWriter = new PrintWriter(stringWriter);
            thrown.printStackTrace(printWriter);
            stackTrace = stringWriter.toString();
        } else {
            stackTrace = getSimpleStacktraceAsString(thrown);
        }

        builder.additionalField("exceptionClass", thrown.getClass().getCanonicalName());
        builder.additionalField("exceptionMessage", thrown.getMessage());
        builder.additionalField("exceptionStackTrace", stackTrace);

        builder.fullMessage(formattedMessage);
    }

    if (!additionalFields.isEmpty()) {
        builder.additionalFields(additionalFields);
    }

    final GelfMessage gelfMessage = builder.build();
    try {
        final boolean sent = client.trySend(gelfMessage);
        if (!sent) {
            LOG.debug("Couldn't send message: {}", gelfMessage);
        }
    } catch (Exception e) {
        throw new AppenderLoggingException("failed to write log event to GELF server: " + e.getMessage(), e);
    }
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:81,代码来源:GelfAppender.java


示例20: setUp

import org.graylog2.gelfclient.GelfMessage; //导入依赖的package包/类
@Before
public void setUp() {
    when(mockedGelfTransport.trySend(any(GelfMessage.class))).thenReturn(true);
}
 
开发者ID:graylog-labs,项目名称:log4j2-gelf,代码行数:5,代码来源:GelfAppenderThrowableTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java YamlRepresenter类代码示例发布时间:2022-05-23
下一篇:
Java ApplicationUser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap