You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-169Lines changed: 2 additions & 169 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The purpose of this project is to create a logging framework to allow developers
10
10
integrate Splunk best practice logging semantics into their code and easily send their log events to Splunk.
11
11
There are also custom handler/appender implementations and config examples for the most prevalent Java logging frameworks in play.
12
12
13
-
1.LogBack
13
+
1.LogBack
14
14
2. Log4j 1.x
15
15
3. Log4j 2
16
16
4. java.util logging
@@ -117,171 +117,4 @@ resources to your computer. For example, use the following command:
117
117
118
118
## Contact
119
119
120
-
This project was initiated by Damien Dallimore
121
-
<table>
122
-
123
-
<tr>
124
-
<td><em>Email</em></td>
125
-
<td>damien@baboonbones.com</td>
126
-
</tr>
127
-
128
-
<tr>
129
-
<td><em>Twitter</em>
130
-
<td>@damiendallimore</td>
131
-
</tr>
132
-
133
-
<tr>
134
-
<td><em>Splunkbase.com</em>
135
-
<td>damiend</td>
136
-
</tr>
137
-
138
-
</table>
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
=======
153
-
# Splunk Java Logging Framework
154
-
155
-
156
-
## Overview
157
-
158
-
The purpose of this project is to create a logging framework to allow developers to as seamlessly as possible
159
-
integrate Splunk best practice logging semantics into their code and easily send their log events to Splunk.
160
-
There are also custom handler/appender implementations and config examples for the most prevalent Java logging frameworks in play.
161
-
162
-
1. LogBack
163
-
2. Log4j 1.x
164
-
3. Log4j 2
165
-
4. java.util logging
166
-
167
-
This framework contains :
168
-
169
-
* java.util.logging handler for logging to Splunk REST endpoints
170
-
* java.util.logging handler for logging to Splunk Raw TCP Server Socket
171
-
* java.util.logging handler for logging to Splunk HEC Endpoint
172
-
* Log4j appender for logging to Splunk REST endpoints
173
-
* Log4j appender for logging to Splunk Raw TCP Server Socket
174
-
* Log4j appender for logging to Splunk HEC Endpoint
175
-
* Logback appender for logging to Splunk REST endpoints
176
-
* Logback appender for logging to Splunk Raw TCP Server Socket
177
-
* Logback appender for logging to Splunk HEC Endpoint
178
-
* Log4j 2 appender for logging to Splunk HEC Endpoint
179
-
* Log4j 2 config examples for TCP and UDP logging
180
-
* Example logging configuration files for all the above
181
-
* Javadocs
182
-
183
-
If you want to use UDP to send events to Splunk , then Log4j 1.x and Logback already have Syslog Appenders.
184
-
Log4j 2 has a UDP Appender and Syslog Appender.
185
-
And of course you can still use any File appenders and have the file monitored by a Splunk Universal Forwarder.
186
-
187
-
I generally recommend using the raw TCP or HEC handlers/appenders I have provided , they perform the best, and have features coded into them for auto connection re-establishment and configurable buffering of log events which will get flushed upon reconnection.
188
-
189
-
## Logging frameworks galore
190
-
191
-
Log4j 2 and Log4j 1.x are very distinct from one another.
192
-
Logback was actually the "new version" of Log4j 1.x , and then Log4J 2 attempted to improve upon Logback.
193
-
This rather convoluted family tree has essentially transpired with 3 different logging frameworks in play, each with different characteristics.
194
-
Log4j 1.x still has a very large legacy usage base in enterprise software therefore warrants addressing with its own custom appenders and example configurations.
195
-
196
-
## Splunk Universal Forwarder vs Splunk Java Logging
197
-
198
-
I always advocate the best practice of using a Splunk Universal Forwarder(UF) monitoring local files wherever possible.
199
-
Not only do you get the features inherent in the UF, but you get the added resiliency of the persistence of files.
200
-
However, there are going to be situations where, for whatever reason(technical or bureaucratic), that a UF can not
201
-
be deployed.In this case, Splunk Java Logging can be used to forward events to Splunk.
202
-
Furthermore, in either scenario, you can still utilize the SplunkLogEvent class to construct your log events in best practice
203
-
semantic format.
204
-
205
-
206
-
## Resilience
207
-
208
-
The HTTP REST ,Raw TCP and HEC handler/appenders have autonomous socket reconnection logic in case of connection failures.
209
-
There is also internal event queuing that is loosely modelled off Splunk's outputs.conf for Universal Forwarders.
210
-
You can set these propertys :
211
-
* maxQueueSize : defaults to 500KB , format [integer|integer[KB|MB|GB]]
212
-
* dropEventsOnQueueFull : defaults to false , format [ true | false]
213
-
214
-
And you can use a parallel File appender if you absolutely need disk persistence.
215
-
216
-
## Data Cloning
217
-
218
-
If you want "data cloning" functionality, then you can leverage the logging configuration and have (n) different appender
219
-
definitions for your various target Indexers.
220
-
221
-
## Load Balancing
222
-
223
-
If you wish to have load balancing of your log events, then configure your logging appenders to send to a Splunk Universal Forwarder acting
224
-
as a load balancing intermediary before you Indexer Cluster.
225
-
226
-
## Failover
227
-
228
-
Log4J 2 has a Failover appender you can use : http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
229
-
There is an example in config/log4j2.xml
230
-
231
-
## Routing
232
-
233
-
Log4J 2 has a Routing appender you can use : http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender
234
-
235
-
## Thread Safety
236
-
237
-
Log4j and Logback are thread safe.
238
-
239
-
## License
240
-
241
-
The Splunk Java Logging Framework is licensed under the Apache 2.0 License.
242
-
Details can be found in the file LICENSE.
243
-
244
-
## Quick Start
245
-
246
-
1. Untar releases/splunklogging-1.3.tar.gz
247
-
2. All the required jar files are in the lib directory..
248
-
3. Assume you know how to setup your classpath to use your preferred logging framework implementation.
249
-
4. There is a simple code example here https://github.com/damiendallimore/SplunkJavaLogging/blob/master/src/com/splunk/logging/examples/Example.java
250
-
5. There are sample logging config files in the config directory for the 4 logging frameworks
251
-
252
-
## Splunk
253
-
254
-
If you haven't already installed Splunk, download it here:
255
-
http://www.splunk.com/download. For more about installing and running Splunk
256
-
and system requirements, see Installing & Running Splunk
257
-
(http://dev.splunk.com/view/SP-CAAADRV).
258
-
259
-
## Contribute
260
-
261
-
Get the Splunk Java Logging Framework from GitHub (https://github.com/) and clone the
262
-
resources to your computer. For example, use the following command:
0 commit comments