This is library for appender to Graylog2 server in GELF format (http://docs.graylog.org/en/2.2/pages/gelf.html).
- graylogHost - hostname of Graylog server. In format 'protocol:hostname'. At this moment only UDP and TCP are supported. Example: tcp:localhost
- port - Graylog server listen port. In case not set default 12201 will be used.
- blocking - true in case old blocking IO must be used. Default is false.
- soTimeout - socket timeout in milliseconds in case blocking set to true. Default: 2000
- facility - facility used for logging. Default : gelf4j-appender
- logExceptions - true in case exception must be logged as full_message. Default: true
- logThread - true in case execution thread must be logged as separate field. Default: true
- logLine - true in case execution line must be logged as separate field. Default: false
- logFile - true in case execution file must be logged as separate field. Default: false
- logMethod - true in case execution method must be logged as separate field. Default: false
- logClass - true in case execution class must be logged as separate field. Default: false
- logLogger - true in case logger name must be logged as separate field. Default: false
- logMdcValues - true in case MDC fields must be logged each as separate field. Default: false
- sendBufferSize - send buffer size in bytes in case non blocking IO used. Default -1 - means use system defaults.
- useCompression - true in case GZIP compression for UDP packets will be used. Default: false
- compressionLevel - compression level of the package. Default : 5
- compressionLimit - mininum size of payload to apply compression. Default : 8192
- useCircuitBreaker - true in case Circuit breaker must be used to minimize IO operations in case lost of failures.
- failuresToOpen - number of IO failures needed to open circuit breaker.
- secondsToRecover - seconds to recover after failures.
Appender for log4j version 1.2 is
org.graylog2.gelf4j.appenders.Log4jGelfAppender
Example configuration looks like
log4j.rootLogger=DEBUG, gelf_appender
log4j.appender.gelf_appender=org.graylog2.gelf4j.appenders.Log4jGelfAppender
log4j.appender.gelf_appender.graylogHost=tcp:localhost
log4j.appender.gelf_appender.blocking=true
log4j.appender.gelf_appender.useCircuitBreaker=true
log4j.appender.gelf_appender.useCompression=true
log4j.appender.gelf_appender.layout=org.apache.log4j.PatternLayout
log4j.appender.gelf_appender.layout.ConversionPattern=%p %d{MMdd-HHmm:ss,SSS} %-4r [%t] \
[%X{process}] %c{1} - %m%n
Appender for log4j version 2.8 is
org.graylog2.gelf4j.appenders.Log4j2GelfAppender
Note!
Hostname in version 2.8 must be set without connection type. Use type of the protocol as :
- type - connection type. One of tcp or udp.
Example configuration looks like
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Gelf4j2 name="syslogtest" hostname="localhost" type="tcp">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<KeyValuePair key="additionalField1" value="additional value 1"/>
</Gelf4j2>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="syslogtest"/>
</Root>
</Loggers>
</Configuration>