Skip to content

Commit 995c772

Browse files
author
Damien Dallimore
committed
updated docs
1 parent 4adaf7d commit 995c772

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Splunk Java Logging Framework
22

33
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.
66

77
1. LogBack
8-
2. Log4j
9-
3. java.util logging
8+
2. Log4j 1.x
9+
3. Log4j 2
10+
4. java.util logging
1011

1112
This framework contains :
1213

@@ -20,9 +21,21 @@ This framework contains :
2021
* Example logging configuration files
2122
* Javadocs
2223

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.
2426
And of course you can still use any File appenders and have the file monitored by a Splunk Universal Forwarder.
2527

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+
2639
## Splunk Universal Forwarder vs Splunk Java Logging
2740

2841
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
3245
Furthermore, in either scenario, you can still utilize the SplunkLogEvent class to construct your log events in best practice
3346
semantic format.
3447

35-
#Log4J2
36-
37-
I have included a sample configuration file for sending events to Splunk over raw TCP and UDP
3848

3949
## Resilience
4050

@@ -59,6 +69,11 @@ as a load balancing intermediary before you Indexer Cluster.
5969
## Failover
6070

6171
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
6277

6378
## Thread Safety
6479

config/log4j2.xml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!--Example log4j2 configuration using a Splunk Raw TCP and UDP Appender-->
3+
<!--Example log4j2 configuration using a Splunk Raw TCP and UDP Appender -->
44

55

66
<Configuration status="info" name="MySplunkApp" packages="">
77

88
<Appenders>
99

10-
<Socket name="splunkrawtcp" protocol="TCP" host="ubuntu-splunk" port="5151">
10+
<Socket name="splunkrawtcp" protocol="TCP" host="ubuntu-splunk"
11+
port="5151">
1112
<PatternLayout pattern="%m%n" />
1213
</Socket>
13-
14-
<Socket name="splunkrawudp" protocol="UDP" host="ubuntu-splunk" port="5152">
14+
15+
<Socket name="splunkrawudp" protocol="UDP" host="ubuntu-splunk"
16+
port="5152">
1517
<PatternLayout pattern="%m%n" />
1618
</Socket>
1719

1820

1921
<Console name="stdout" target="SYSTEM_OUT">
2022
<PatternLayout pattern="%m%n" />
2123
</Console>
24+
25+
<Failover name="failover_example" primary="splunkrawtcp">
26+
<Failovers>
27+
<AppenderRef ref="stdout" />
28+
</Failovers>
29+
</Failover>
30+
2231
</Appenders>
2332

2433
<Loggers>
@@ -27,7 +36,8 @@
2736
</Root>
2837
<logger name="splunk.logger" additivity="false" level="INFO">
2938
<appender-ref ref="splunkrawtcp" />
30-
<appender-ref ref="splunkrawudp" />
39+
<!-- <appender-ref ref="splunkrawudp" /> -->
40+
<!-- <appender-ref ref="failover_example" /> -->
3141
</logger>
3242
</Loggers>
3343

releases/splunklogging-1.0.tar.gz

30 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)