forked from pstehlik/gelf4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
81 lines (57 loc) · 2.76 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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:
'additionalFields'
Set as a java Collection in your config to include additional fields to send to graylog2 server.
Default: empty/no additional fields added
'facility'
Set the facility number to use.
Default: 'GELF'
'graylogServerHost'
The host name of your graylog server. Maintained as String.
Default: 'localhost'
'graylogServerPort'
The port of your graylog server. Maintained as Integer.
Default: 12201
'host'
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'
'logStackTraceFromMessage'
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
log.error(myException)
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)
'maxChunkSize'
The amount of bytes a message chunk can contain.
Default: 8154
---
A working example of a GELF appender in a log4j.properties file would be
# GELF appender
log4j.appender.GELF=com.pstehlik.groovy.gelf4j.appender.Gelf4JAppender
log4j.appender.GELF.graylogServerHost=my.gelf.host
log4j.appender.GELF.host=www13
log4j.appender.GELF.facility=local1
# use the GELF appender. set the level to INFO.
log4j.category.com.my.class.where.i.DoLogging=INFO, GELF
---
Notes:
- 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.
---