Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

GELF log4j Appender for server

branch: master
gelf4j created by Philip Stehlik - Copyright 2011
See LICENSE for license details


gelf4j is set out to be an easy to use log4j appender to log to graylog2 via GELF messages.


Build with gradle via `gradle build` from the root directory


Deploy by placing the gelf4j.jar file in your class path.
If you don't have Groovy 1.7.6 already in your deployment, also place the groovy-all-1.7.6.jar in your classpath.
Of course you need log4j as well. gelf4j is built against version 1.2.16.

In a future release I hope to bundle this all up in a pom or so for easier distribution.


Configure the log4j appender by setting the appender class as usual and maintaining the additional configurations for the appender.
The appender's class is com.pstehlik.groovy.gelf4j.appender.Gelf4JAppender

Additional configuration options:

Set as a java Collection in your config to include additional fields to send to graylog2 server.
Default: empty/no additional fields added

Set the facility number to use.
Default: 'GELF'

The host name of your graylog server. Maintained as String.
Default: 'localhost'

The port of your graylog server. Maintained as Integer.
Default: 12201

Sets the host name that should be mentioned in the GELF message
Default: Name of the host that runs the JVM with fallback to 'unknown_host'

Defines if a logged Throwable should be logged with the complete stack trace or just with the info returned by
the toString() implementation on the Throwable (which is usually calling getMessage()).
This applies to messages logged by doing things like
message logged via
  log.error("Oh... something bad happened", myException)
have the stack trace logged and you can't change that.

If you always want to have the stack trace in your logs you should set logStackTraceFromMessage to true (which is recommended).
Default: false (for backwards compatibility)

The amount of bytes a message chunk can contain.
Default: 8154


A working example of a GELF appender in a file would be
# GELF appender

# use the GELF appender. set the level to INFO., GELF


- The 'short_message' of the GELF messages is limited to 250 chars and just takes the first 250 chars of the log4j message. The 'full_message' contains the full log4j text.
- The appender does not layout the message according to a message layout. It sends all the fields to the graylog2 server where you can query/look at the log.

Something went wrong with that request. Please try again.