I'm using the Splunk HttpEventCollectorLogbackAppender to automatically send application logs to Splunk. I've been trying to set the host, source, and sourcetype but am not having any luck getting them sent to Splunk.
Is it possible to set the host, source, or sourcetype using the Splunk HttpEventCollectorLogbackAppender and if so, how do I do it?
I've been trying to send JSON and it doesn't seem to be working.
Here's the documentation that tells you what options are available and it says that they need to be passed as a query string, but since i'm using the out of the box Splunk appender i'm not sure how to set those.
http://dev.splunk.com/view/event-collector/SP-CAAAE6P
Splunk logback appender:
...
<!-- SPLUNK appender -->
<appender name="SPLUNK" class="com.splunk.logging.HttpEventCollectorLogbackAppender">
<url>http://myurl:8088</url>
<token>mytoken</token>
<disableCertificateValidation>true</disableCertificateValidation>
<batch_size_count>1</batch_size_count>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%logger: %msg%n</pattern>
</layout>
</appender>
<root level="INFO">
<appender-ref ref="SPLUNK"/>
</root>
...
Example log line
Logger logger = LoggerFactory.getLogger(MyClass.class);
logger.debug("I'm logging debug stuff");
Any setters on HttpEventCollectorLogbackAppender can be added to your logback configuration.
So to invoke setHost
, setSource
and setSourcetype
you add them to your logback configuration like this:
<appender name="SPLUNK" class="com.splunk.logging.HttpEventCollectorLogbackAppender">
<url>http://myurl:8088</url>
<host>x</host>
<source>y</source>
<sourcetype>z</sourcetype>
<token>mytoken</token>
<disableCertificateValidation>true</disableCertificateValidation>
<batch_size_count>1</batch_size_count>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%logger: %msg%n</pattern>
</layout>
</appender>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With