logback-gelf
logback-gelf copied to clipboard
GelfMessage should fail on host = "", shortmessage=""
Describe the bug We have a logging with a short message "" (coming from the root cause NullPointerException)
GelfMessage checks for null but not empty message. Our Graylog server silently skips a message with short_message = "" even if full message is filled properly
this.host = Objects.requireNonNull(host, "host must not be null");
this.shortMessage = Objects.requireNonNull(shortMessage, "shortMessage must not be null");
should be changed to something like
this.host = requireNotEmpty(host, "host must not be empty");
this.shortMessage = requireNotEmpty(shortMessage, "shortMessage must not be empty");
[...]
private static void requireNotEmpty(String value, String message) {
if (value == null || value.trim().isEmpty()) {
throw new IllegalStateException(message);
}
}
insert test code here
Related: https://github.com/Graylog2/graylog2-server/issues/5171
Which version of graylog-server do you use?
Graylog2/graylog2-server#5171
Graylog 3.3.16+f766a24
According to GelfCodec.java, Graylog requires a short_message
that "is not blank" (by using Apache Commons Lang3 StringUtils). The definition of blank by org.apache.commons.lang3.StringUtils#isBlank
:
Checks if a CharSequence is empty (""), null or whitespace only. Whitespace is defined by Character.isWhitespace(char).
So this will be changed in the next release of this library.