1
1
# Splunk Java Logging Framework
2
2
3
3
The purpose of this project is to create a logging framework to allow developers to as seamlessly as possible
4
- integrate Splunk best practice logging semantics into their code.
5
- There are also custom handler/appender implementations for the 3 most prevalent Java logging frameworks in play.
4
+ integrate Splunk best practice logging semantics into their code and easily send their log events to Splunk .
5
+ There are also custom handler/appender implementations and config examples for the most prevalent Java logging frameworks in play.
6
6
7
7
1. LogBack
8
- 2. Log4j
9
- 3. java.util logging
8
+ 2. Log4j 1.x
9
+ 3 . Log4j 2
10
+ 4. java.util logging
10
11
11
12
This framework contains :
12
13
@@ -20,9 +21,21 @@ This framework contains :
20
21
* Example logging configuration files
21
22
* Javadocs
22
23
23
- If you want to use UDP to send events to Splunk , then Log4j and Logback already have Syslog Appenders.
24
+ If you want to use UDP to send events to Splunk , then Log4j 1.x and Logback already have Syslog Appenders.
25
+ Log4j 2 has a UDP Appender and Syslog Appender.
24
26
And of course you can still use any File appenders and have the file monitored by a Splunk Universal Forwarder.
25
27
28
+ I generally recommend using the raw TCP handlers/appenders I have provided , they perform the best, and have features coded into them for
29
+ auto connection re-establishment and configurable buffering of log events which will get flushed upon reconnection.
30
+
31
+ ## Logging frameworks galore
32
+
33
+ Log4j 2 and Log4j 1.x are very distinct from one another.
34
+ Logback was actually the "new version" of Log4j 1.x , and then Log4J 2 attempted to improve upon Logback.
35
+ This rather convoluted family tree has essentially transpired with 3 different logging frameworks in play, each with different characteristics.
36
+ Log4j 1.x still has a very large legacy usage base in enterprise software therefore warrants addressing with its own custom appenders
37
+ and example configurations.
38
+
26
39
## Splunk Universal Forwarder vs Splunk Java Logging
27
40
28
41
I always advocate the best practice of using a Splunk Universal Forwarder(UF) monitoring local files wherever possible.
@@ -32,9 +45,6 @@ be deployed.In this case, Splunk Java Logging can be used to forward events to S
32
45
Furthermore, in either scenario, you can still utilize the SplunkLogEvent class to construct your log events in best practice
33
46
semantic format.
34
47
35
- #Log4J2
36
-
37
- I have included a sample configuration file for sending events to Splunk over raw TCP and UDP
38
48
39
49
## Resilience
40
50
@@ -59,6 +69,11 @@ as a load balancing intermediary before you Indexer Cluster.
59
69
## Failover
60
70
61
71
Log4J 2 has a Failover appender you can use : http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
72
+ There is an example in config/log4j2.xml
73
+
74
+ ## Routing
75
+
76
+ Log4J 2 has a Routing appender you can use : http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
62
77
63
78
## Thread Safety
64
79
0 commit comments