Skip to content

Commit 88b01ae

Browse files
author
Damien Dallimore
committed
Resolved merge conflict
2 parents be376e6 + d72045c commit 88b01ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3511
-14
lines changed

.DS_Store

6 KB
Binary file not shown.

.classpath

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="lib" path="lib/commons-codec-1.9.jar"/>
5+
<classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/>
6+
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
7+
<classpathentry kind="lib" path="lib/httpasyncclient-4.1.jar"/>
8+
<classpathentry kind="lib" path="lib/httpasyncclient-cache-4.1.jar"/>
9+
<classpathentry kind="lib" path="lib/httpclient-4.4.1.jar"/>
10+
<classpathentry kind="lib" path="lib/httpclient-cache-4.4.1.jar"/>
11+
<classpathentry kind="lib" path="lib/httpcore-4.4.1.jar"/>
12+
<classpathentry kind="lib" path="lib/httpcore-nio-4.4.1.jar"/>
13+
<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
14+
<classpathentry kind="lib" path="lib/log4j-api-2.3.jar"/>
15+
<classpathentry kind="lib" path="lib/log4j-core-2.3.jar"/>
16+
<classpathentry kind="lib" path="lib/log4j-slf4j-impl-2.3.jar"/>
17+
<classpathentry kind="lib" path="lib/logback-classic-1.0.0.jar"/>
18+
<classpathentry kind="lib" path="lib/logback-core-1.0.0.jar"/>
19+
<classpathentry kind="lib" path="lib/slf4j-api-1.6.4.jar"/>
20+
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.6.4.jar"/>
21+
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.6.4.jar"/>
22+
<classpathentry kind="lib" path="lib/splunk_tlsv12.jar"/>
23+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
24+
<classpathentry kind="output" path="classes"/>
25+
</classpath>

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>SplunkJavaLogging</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
5+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6+
org.eclipse.jdt.core.compiler.compliance=1.7
7+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
8+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
9+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.source=1.7

LICENSE

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,6 @@
176176

177177
END OF TERMS AND CONDITIONS
178178

179-
APPENDIX: How to apply the Apache License to your work.
180-
181-
To apply the Apache License to your work, attach the following
182-
boilerplate notice, with the fields enclosed by brackets "[]"
183-
replaced with your own identifying information. (Don't include
184-
the brackets!) The text should be enclosed in the appropriate
185-
comment syntax for the file format. We also recommend that a
186-
file or class name and description of purpose be included on the
187-
same "printed page" as the copyright notice for easier
188-
identification within third-party archives.
189-
190-
Copyright [yyyy] [name of copyright owner]
191-
192179
Licensed under the Apache License, Version 2.0 (the "License");
193180
you may not use this file except in compliance with the License.
194181
You may obtain a copy of the License at
@@ -199,4 +186,4 @@
199186
distributed under the License is distributed on an "AS IS" BASIS,
200187
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201188
See the License for the specific language governing permissions and
202-
limitations under the License.
189+
limitations under the License.

README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,139 @@ This project was initiated by Damien Dallimore
149149

150150

151151

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:
263+
264+
> git clone https://github.com/damiendallimore/SplunkJavaLogging.git
265+
266+
267+
## Contact
268+
269+
This project was initiated by Damien Dallimore
270+
<table>
271+
272+
<tr>
273+
<td><em>Email</em></td>
274+
<td>damien@baboonbones.com</td>
275+
</tr>
276+
277+
<tr>
278+
<td><em>Twitter</em>
279+
<td>@damiendallimore</td>
280+
</tr>
281+
282+
<tr>
283+
<td><em>Splunkbase.com</em>
284+
<td>damiend</td>
285+
</tr>
286+
287+
</table>

classes/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/com/

0 commit comments

Comments
 (0)