Name: gelfj
Owner: racker
Description: Graylog Extended Log Format (GELF) implementation in Java and log4j appender without any dependencies.
Created: 2012-02-09 20:38:00.0
Updated: 2013-01-07 19:43:12.0
Pushed: 2012-03-27 17:35:25.0
Homepage: https://github.com/t0xa/gelfj/wiki
Size: 238
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
It's very simple GELF implementation in pure Java with the Log4j appender and JDK Logging Handler. It supports chunked messages which allows you to send large log messages (stacktraces, environment variables, additional fields, etc.) to a Graylog2 server.
Drop the latest JAR into your classpath and configure Log4j to use it.
GelfAppender will use the log message as a short message and a stacktrace (if exception available) as a long message if “extractStacktrace” is true.
To use GELF Facility as appender in Log4j (XML configuration format):
<appender name="graylog2" class="org.graylog2.log.GelfAppender">
<param name="graylogHost" value="192.168.0.201"/>
<param name="originHost" value="my.machine.example.com"/>
<param name="extractStacktrace" value="true"/>
<param name="addExtendedInformation" value="true"/>
<param name="facility" value="gelf-java"/>
<param name="Threshold" value="INFO"/>
<param name="additionalFields" value="{'environment': 'DEV', 'application': 'MyAPP'}"/>
</appender>
and then add it as a one of appenders:
<root>
<priority value="INFO"/>
<appender-ref ref="graylog2"/>
</root>
Or, in the log4j.properties format:
# Define the graylog2 destination
log4j.appender.graylog2=org.graylog2.log.GelfAppender
log4j.appender.graylog2.graylogHost=graylog2.example.com
log4j.appender.graylog2.originHost=my.machine.example.com
log4j.appender.graylog2.facility=gelf-java
log4j.appender.graylog2.layout=org.apache.log4j.PatternLayout
log4j.appender.graylog2.extractStacktrace=true
log4j.appender.graylog2.addExtendedInformation=true
log4j.appender.graylog2.additionalFields={'environment': 'DEV', 'application': 'MyAPP'}
# Send all INFO logs to graylog2
log4j.rootLogger=INFO, graylog2
GelfAppender supports the following options:
Configured via properties as a standard Handler like
handlers = org.graylog2.logging.GelfHandler
.level = ALL
org.graylog2.logging.GelfHandler.level = ALL org.graylog2.logging.GelfHandler.graylogHost = syslog.example.com
.handlers=org.graylog2.logging.GelfHandler
The Graylog Extended Log Format (GELF) avoids the shortcomings of classic plain syslog:
You can get more information here: http://www.graylog2.org/about/gelf