Logback appender that sends GELF messages
This logback appender logs messages to a Graylog server. It’s using the official GELF Java client to connect to the remote server. It’s inspired and influenced greatly by the Log4j2 GELF Appender.
The appender has several configurable properties:
server
(default: localhost
)port
(default: 12201
)hostName
(default: the local host name or localhost
if it couldn’t be detected)protocol
(default: UDP
)includeSource
(default: true
)includeMDC
(default: true
)includeStackTrace
(default: true
)includeLevelName
(default: false
)queueSize
(default: 512
)connectTimeout
(default: 1000
)reconnectDelay
(default: 500
)sendBufferSize
(default: -1
)tcpNoDelay
(default: false
)tcpKeepAlive
(default: false
)layout
(default: "%m %n"
)short_message
(exception stacktraces are not included in this message)additionalFields
<configuration debug="true">
<appender name="gelf" class="de.appelgriepsch.logback.GelfAppender">
<server>localhost</server>
<port>12201</port>
<hostName>localhost</hostName>
<protocol>UDP</protocol>
<includeSource>true</includeSource>
<includeMDC>true</includeMDC>
<queueSize>512</queueSize>
<connectTimeout>1000</connectTimeout>
<reconnectDelay>500</reconnectDelay>
<additionalFields>cow=moo,cat=meow</additionalFields>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%.-25m</pattern>
</layout>
</appender>
<root level="DEBUG">
<appender-ref ref="gelf" ></appender-ref>
</root>
</configuration>
GELF Appender for Logback
Copyright (C) 2019 Sandra Thieme thieme.sandra@gmail.com
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.