handlers=org.graylog2.logging.GelfHandler
.handlers=org.graylog2.logging.GelfHandler
.level = ALL
org.graylog2.logging.GelfHandler.level = ALL
org.graylog2.logging.GelfHandler.amqpURI=amqp://just.a.test
org.graylog2.logging.GelfHandler.amqpExchangeName=messages
org.graylog2.logging.GelfHandler.amqpRoutingKey=gelfudp
org.graylog2.logging.GelfHandler.amqpMaxRetries=5
org.graylog2.logging.GelfHandler.extractStacktrace = true
then the code will throw a NullPointerException in org.graylog2.logging.GelfHandler.publish(LogRecord) at location
if (graylogHost.startsWith("tcp:")) {
graylogHost is null in the described case.
Here's a test case to reproduce the bug, using the configuration from above as file "logging-only-amqp-test.properties":
@Test
public void testConfigureOnlyAmqpLogging() throws SecurityException, IOException {
// In versions <= 1.1.16 there's a bug that throws a NullPointerException if you
// only configure amqp but leave graylogHost empty
InputStream is = GelfHandlerTest.class.getResourceAsStream("logging-only-amqp-test.properties");
LogManager.getLogManager().readConfiguration(is);
GelfHandler gelfHandler = new GelfHandler();
gelfHandler.publish(new LogRecord(Level.INFO, "testMessage"));
}
If you configure for example the following:
then the code will throw a NullPointerException in org.graylog2.logging.GelfHandler.publish(LogRecord) at location
graylogHost is null in the described case.
Here's a test case to reproduce the bug, using the configuration from above as file "logging-only-amqp-test.properties":