<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Log4j Splunk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53003#M96823</link>
    <description>&lt;P&gt;Ok thanks. If I wang to use TCP, I just to import org.slf4j.LoggerFactory to format my reglar string log to index correctly in splunk.&lt;/P&gt;</description>
    <pubDate>Tue, 22 May 2012 19:54:29 GMT</pubDate>
    <dc:creator>LauraBre</dc:creator>
    <dc:date>2012-05-22T19:54:29Z</dc:date>
    <item>
      <title>Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52994#M96814</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I work with Eclipse. I want to send my log on the port listened by Splunk. So I add this code in log4j.properties :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;log4j.logger.net.awl.bfi.TokenizerWatchdogSplunk=info,watchdogSplunkSocket
log4j.appender.watchdogSplunkSocket=org.apache.log4j.net.SyslogAppender
log4j.appender.watchdogSplunkSocket.SyslogHost=    [:CustomPort]log4j.appender.watchdogSplunkSocket.remoteHost=localhost
log4j.appender.watchdogSplunkSocket.port=5540
log4j.appender.watchdogSplunkSocket.locationInfo=true
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
log4j.appender.watchdogSplunkSocket.Facility=USER
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I managed to recover the file in Splunk but there are a lot of caracters that to add in my log file. For example I had the following event in Splunk :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sr\x00!org.apache.log4j.spi.LoggingEvent\xF3\xF2\xB9#t\xB\xB5?\x3\x00Z\x00\x15mdcCopyLookupRequiredZ\x00\x11ndcLookupRequiredJ\x00  timeStampL\x00\xCcategoryNamet\x00\x12Ljava/lang/String;L\x00\xClocationInfot\x00#Lorg/apache/log4j/spi/LocationInfo;L\x00\x7mdcCopyt\x00\x15Ljava/util/Hashtable;L\x00\x3ndcq\x00~\x00\x1L\x00\xFrenderedMessageq\x00~\x00\x1L\x00threadNameq\x00~\x00\x1L\x00throwableInfot\x00+Lorg/apache/log4j/spi/ThrowableInformation;xp\x00\x00\x00\x00\x17Q7\xA6\xE0t\x00#net.awl.bfi.TokenizerWatchdogSplunksr\x00!org.apache.log4j.spi.LocationInfo홻\xE1J\x91\xA5|\x2\x00\x1L\x00\x8fullInfoq\x00~\x00\x1xpt\x00Dnet.awl.bfi.eipengine.beans.MapInfoBean.process(MapInfoBean.java:86)ppt\x00URequested serv. : D2T, Nb PAN : 1, Requester : a187571, User : a508404, Host : W60080t\x00\x15ActiveMQ Session Taskpw\x4\x00\x00N pxysr\x00!org.apache.log4j.spi.LoggingEvent\xF3\xF2\xB9#t\xB\xB5?\x3\x00Z\x00
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I just add Requested serv. : D2T, Nb PAN : 1, Requester : a187571, User : a508404, Host : W60080t in my log.&lt;/P&gt;

&lt;P&gt;Can I resolve this problem???&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 07:58:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52994#M96814</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2012-05-16T07:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52995#M96815</link>
      <description>&lt;P&gt;Not very familiar with log4j, but the output that reaches Splunk seems to be in some kind of binary format rather than just plain ascii. You'll probably need to configure log4j to get a valid output format.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 09:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52995#M96815</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-05-16T09:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52996#M96816</link>
      <description>&lt;P&gt;For some reason you have sent a serialized Java object (binary data) to Splunk rather than a textual log message.What does your logging statement in your code look like ?&lt;/P&gt;

&lt;P&gt;You might want to check out SplunkJavaLogging , available on &lt;A href="https://github.com/damiendallimore/SplunkJavaLogging"&gt;Github&lt;/A&gt; or via &lt;A href="http://dev.splunk.com/view/community-projects/SP-CAAAED7"&gt;dev.splunk.com&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Here you will find appenders for log4j and logback that use HTTP REST to send log events to Splunk.&lt;/P&gt;

&lt;P&gt;There are also other utilities to help you format log messages into &lt;A href="http://dev.splunk.com/view/logging-best-practices/SP-CAAADP6"&gt;Splunk best practice logging format&lt;/A&gt; and use the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/UnderstandandusetheCommonInformationModel"&gt;Splunk Common Information Model (CIM)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 09:38:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52996#M96816</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-16T09:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52997#M96817</link>
      <description>&lt;P&gt;In my log lig, I only have messages of this type : &lt;BR /&gt;
Requested serv. : D2T, Nb PAN : 1, Requester : a187571, User : a508404, Host : W60080t&lt;BR /&gt;
When I index directly this file from Splunk, it's perfect. By when I use a port, it's bad. But in eclipse, I use "ganymede Log4j View" to look that there are in the log on the port. When I look it, I see the message in correct format.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 13:16:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52997#M96817</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2012-05-16T13:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52998#M96818</link>
      <description>&lt;P&gt;I'll need to see :&lt;BR /&gt;
1) your full log4j.properties file&lt;BR /&gt;
2) an example of how you are logging in your Java code&lt;BR /&gt;
3) the inputs.conf stanza for the UDP input in Splunk&lt;/P&gt;

&lt;P&gt;Mask out any sensitive/confidential information.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2012 22:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52998#M96818</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-16T22:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52999#M96819</link>
      <description>&lt;P&gt;log4j.properties : &lt;/P&gt;

&lt;P&gt;log4j.logger.net.awl.bfi.TokenizerWatchdogSplunk=info,watchdogSplunkSocket&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket=org.apache.log4j.net.SyslogAppender&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.remoteHost=odpcil01b&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.port=5541&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.locationInfo=false&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.layout=org.apache.log4j.PatternLayout &lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.layout.ConversionPattern = [%-5p][%d{dd/MM/yyyy HH:mm:ss}][%c][%F]%m%n&lt;BR /&gt;
log4j.appender.watchdogSplunkSocket.Facility=USER&lt;/P&gt;

&lt;P&gt;I don't know if I have to use a SylogAppender or SocketAppender.&lt;/P&gt;

&lt;P&gt;I am logging in my Java code as this:&lt;BR /&gt;
LOGGER_SPLUNK.info("Requested serv. : D2T, Nb PAN : " + nbPan +", Requester : " + body.get(NlvValue.REQUESTER_ID) +", User : " + body.get(NlvValue.USER_ID)+", Host : "+host+" ServiceName : ");&lt;/P&gt;

&lt;P&gt;inputs.conf file : &lt;/P&gt;

&lt;P&gt;[tcp://5541]&lt;BR /&gt;
connection_host = none&lt;BR /&gt;
sourcetype = log4j&lt;/P&gt;

&lt;P&gt;Thanks by advance,&lt;/P&gt;

&lt;P&gt;Laura&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:50:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/52999#M96819</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2020-09-28T11:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53000#M96820</link>
      <description>&lt;P&gt;You have a &lt;STRONG&gt;TCP&lt;/STRONG&gt; port open in Splunk and the log4j appender "org.apache.log4j.net.SyslogAppender" is &lt;STRONG&gt;UDP&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;Also , your log4j.properties looks wrong.&lt;BR /&gt;
SyslogAppender doesn't use the &lt;EM&gt;remoteHost&lt;/EM&gt; and &lt;EM&gt;port&lt;/EM&gt; properties.&lt;BR /&gt;
It use the &lt;EM&gt;syslogHost&lt;/EM&gt; property&lt;/P&gt;

&lt;P&gt;Suggested Corrections :&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;log4j.properties&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;log4j.logger.net.awl.bfi.TokenizerWatchdogSplunk=info,watchdogSplunkSocket log4j.appender.watchdogSplunkSocket=org.apache.log4j.net.SyslogAppender log4j.appender.watchdogSplunkSocket.SyslogHost=odpcil01b: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 log4j.appender.watchdogSplunkSocket.Facility=USER
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;inputs.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[udp://5541] 
connection_host = none 
sourcetype = log4j
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The Log4j SocketAppender won't work because that appender sends a serialized object(binary)&lt;/P&gt;

&lt;P&gt;If you do want to use TCP , then check out &lt;A href="https://github.com/damiendallimore/SplunkJavaLogging"&gt;SplunkJavaLogging&lt;/A&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Log4j and Logback appenders to send
events to Splunk via HTTP REST or Raw
TCP&lt;/LI&gt;
&lt;LI&gt;Helper classes for formatting    log
events in a best practice    semantic
format for Splunk&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Sat, 19 May 2012 04:26:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53000#M96820</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-19T04:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53001#M96821</link>
      <description>&lt;P&gt;Thanks very much but I have a question: When we use UDP, we can lost data packets???&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2012 19:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53001#M96821</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2012-05-22T19:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53002#M96822</link>
      <description>&lt;P&gt;UDP does not guarantee delivery.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2012 19:47:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53002#M96822</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-22T19:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53003#M96823</link>
      <description>&lt;P&gt;Ok thanks. If I wang to use TCP, I just to import org.slf4j.LoggerFactory to format my reglar string log to index correctly in splunk.&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2012 19:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53003#M96823</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2012-05-22T19:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53004#M96824</link>
      <description>&lt;P&gt;If using the Raw TCP Appender from SplunkJavaLogging , it's up to you how you implement your logging code. My preference is to use the slf4j logging facade to abstract the underlying logging implementation (log4j, logback, java.util.logging).And the SplunkLogEvent class is useful for creating your log events in a best practice semantic format.&lt;BR /&gt;
If using slf4j ontop of log4j, you then place the necesssary delegate jars on the classpath(ie:slf4j-log4j12-1.6.4.jar and log4j-1.2.16.jar ) and configure the properties file(ie: log4j.properties).&lt;/P&gt;</description>
      <pubDate>Tue, 22 May 2012 23:08:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53004#M96824</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-22T23:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53005#M96825</link>
      <description>&lt;P&gt;I tried to use SplunkLogEvent  but I don't able to listen the events in splunk and in local. I think there is a problem during the sending.&lt;/P&gt;

&lt;P&gt;This is my log4j file :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#log4j.logger.splunk.logger=INFO, splunkrest
log4j.logger.splunk.logger=INFO, splunkrawtcp
log4j.additivity.splunk.logger=false
.
.
.   
# Send log events to a Splunk Raw TCP server socket
log4j.appender.splunkrawtcp=com.dtdsoftware.splunk.logging.log4j.appender.SplunkRawTCPAppender
log4j.appender.splunkrawtcp.host=odpcil01b
log4j.appender.splunkrawtcp.port=5543
log4j.appender.splunkrawtcp.maxQueueSize=5MB
log4j.appender.splunkrawtcp.dropEventsOnQueueFull=false
log4j.appender.splunkrawtcp.layout=org.apache.log4j.PatternLayout
log4j.appender.splunkrawtcp.layout.ConversionPattern=%m%n
# optionally you can enrich the messages with formatting tokens from the logging framework
#log4j.appender.splunkrawtcp.layout.ConversionPattern=%d{ABSOLUTE} %m%n
#log4j.appender.splunkrawtcp.layout.ConversionPattern=%m loglevel="%p"%n
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For the example, I used the example of the link that you &lt;BR /&gt;
gave me.&lt;/P&gt;

&lt;P&gt;Thanks by advance.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2012 14:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53005#M96825</guid>
      <dc:creator>LauraBre</dc:creator>
      <dc:date>2012-05-23T14:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Log4j Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53006#M96826</link>
      <description>&lt;P&gt;If you are using log4j you can't even log locally(file or console), then perhaps you have either :&lt;BR /&gt;
a) not setup your classpath for slf4j to use log4j correctly.You should only have the log4j bindings on your classpath, you don't need the logback(logback-classic.jar , logback-core.jar) and java.util(slf4j-jdk14-1.6.4.jar) bindings&lt;BR /&gt;
b) log4j.properties is not on your classpath.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2012 21:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Log4j-Splunk/m-p/53006#M96826</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-05-23T21:51:07Z</dc:date>
    </item>
  </channel>
</rss>

