Getting Data In

Splunk Log4J2 Appender in Spring Boot with Maven

ssdarkside2
Explorer

I have a simple Maven configuration where I know the following is on the classpath (I can verify it at runtime before Spring Boot starts up in my application class):

com.splunk.logging:splunk-library-javalogging:1.6.2

The Maven dependency looks like:

<dependency>
  <groupId>com.splunk.logging</groupId>
  <artifactId>splunk-library-javalogging</artifactId>
  <version>1.6.2</version>
</dependency>

 

I made sure that Spring Boot is loaded this way:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <version>${version.spring.boot}</version>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-log4j2</artifactId>
  <version>2.5.4</version>
</dependency>
  

 

I created an appender this way:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" name="LoggingTesting" packages="">
  <Appenders>
    <SplunkHttp name="SPLUNK_APPENDER_1"
                url="http://SPLUNK_IP:8088/services/collector/event"
                token="MY_TOKEN"
                source="SampleJavaAppender1"
                messageFormat="text"
                batch_size_bytes="0"
                batch_size_count="5"
                batch_interval="0"
                connect_timeout="5000"
                disableCertificateValidation="true">
      <PatternLayout pattern="%m"/>
    </SplunkHttp>

 

When I launch my application, I get this error:

main ERROR Error processing element SplunkHttp ([Appenders: null]): CLASS_NOT_FOUND
main ERROR Unable to locate appender "SPLUNK_APPENDER_1" for logger config "root"

This was all based on the sample Log4J2 configuration .

What am I missing in my configuration?

Labels (2)
0 Karma
.conf21 Now Fully Virtual!
Register for FREE Today!

We've made .conf21 totally virtual and totally FREE! Our completely online experience will run from 10/19 through 10/20 with some additional events, too!