Refine your search:

1
1

Does Splunk work with a log4j socket appender? ( not the rolling file one). How?

asked 29 Jul '10, 03:22

ljoshi's gravatar image

ljoshi ♦
36113
accept rate: 100%


5 Answers:

Splunk can listen on a TCP socket for an arbitrary stream of bytes. This should include the output of log4j's socket appender. The inputs.conf stanza for this is similar to:

[tcp://7070]
connection_host=dns
sourcetype=log4j

There's at least one caveat with this approach - your log4j data is not persisted anywhere until it is indexed. If the connectivity between your log4j app and splunk is disrupted, or if the Splunk indexer is down for some reason -- you could lose event data. A forwarder on the log4j host, reading a file produced by the log4j app is more robust in this example.

link

answered 30 Jul '10, 01:23

dwaddle's gravatar image

dwaddle ♦
11.2k1516
accept rate: 34%

Fully agree with bchen, you will get serialized garble in your messages on the splunk index using SocketAppender. Log4j properties example below just alter SyslogHost values. Port is optional, but useful to create various index sources.

We use another appender to created log files of same data, used to fill long term analysis, feed those to splunk in different index.

example for syslog appender log4j log4j.appender.SPLUNKiT=org.apache.log4j.net.SyslogAppender log4j.appender.SPLUNKiT.SyslogHost=[:CustomPort] log4j.appender.SPLUNKiT.layout=org.apache.log4j.PatternLayout log4j.appender.SPLUNKiT.layout.ConversionPattern=sv-cdr-posted - %m log4j.appender.SPLUNKiT.Facility=USER

link

answered 14 Dec '10, 16:36

mawalters1's gravatar image

mawalters1
111
accept rate: 0%

It's unlikely you want to use SocketAppender with Splunk, since it sends a serialized Java object, LoggingEvent, which is meant for something like SocketNode to receive and deserialize.

Something that may have more sensible data is to use SyslogAppender. (though I haven't tried it personally)

link

answered 02 Sep '10, 23:51

bchen's gravatar image

bchen ♦
1141
accept rate: 14%

I read your subject and I hava a question because I hava a similar problem. When I read my events in Splunk the data format is different. There are a lot of characters which haven't be it. Can you show me how you are logging your events. Me, I do it but I think it is bad:

LOGGER_SPLUNK.info("Requested serv. : D2T, Nb PAN : " + nbPan +", Requester : " + body.get(NlvValue.REQUESTER_ID) +", User : " + body.get(NlvValue.REQUESTER_ID)+"_ow, Host : "+host+" ServiceName : ");//+ exchange.getProperty(ConstantUtil.SERVICE_NAME));

this is my log4j.properties:

log4j.logger.net.awl.bfi.TokenizerWatchdogSplunk=info,watchdogSplunkSocket
log4j.appender.watchdogSplunkSocket=org.apache.log4j.net.SocketAppender
log4j.appender.watchdogSplunkSocket.remoteHost=odpcil01b
log4j.appender.watchdogSplunkSocket.port=5541
log4j.appender.watchdogSplunkSocket.locationInfo=false
log4j.appender.watchdogSplunkSocket.layout=org.apache.log4j.PatternLayout 
log4j.appender.watchdogSplunkSocket.layout.ConversionPattern = [%-5p][%d{dd/MM/yyyy HH:mm:ss}][%c][%F]%m%n

Thanks by advance,

Laura

link

answered 18 May, 06:21

LauraBre's gravatar image

LauraBre
312
accept rate: 0%

Check out SplunkJavaLogging

Log4j and Logback appenders to send events to Splunk via HTTP REST or Raw TCP Helper classes for formatting log events in a best practice semantic format for Splunk

link

answered 18 May, 21:11

Damien%20Dallimore's gravatar image

Damien Dalli...
2.6k17
accept rate: 21%

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×37

Asked: 29 Jul '10, 03:22

Seen: 3,135 times

Last updated: 18 May, 21:11

Copyright © 2005-2012 Splunk, Inc. All rights reserved.