Splunk Enterprise

Spunk logging properties file

esmeemarch
Observer

I am trying to integrate splunk into my project.

Currently, I have the following .properties file:

 

mySplunk.level = INFO
mySplunk.handlers = com.splunk.logging.HttpEventCollectorLoggingHandler

# Configure the com.splunk.logging.HttpEventCollectorLoggingHandler
com.splunk.logging.HttpEventCollectorLoggingHandler.url = myUrl
com.splunk.logging.HttpEventCollectorLoggingHandler.level = INFO
com.splunk.logging.HttpEventCollectorLoggingHandler.token = myToken
com.splunk.logging.HttpEventCollectorLoggingHandler.source= mySource
com.splunk.logging.HttpEventCollectorLoggingHandler.disableCertificateValidation=true

 

 

Note: url and token are not put into this file but are available and the access is grated.

My SplunkTestLogger.java

 

import java.util.logging.Logger;
import java.util.logging.Level;

public class Main {

public static void main(String[] args) {
Logger logger = Logger.getLogger("mySplunk");
try{
FileInputStream fis = new FileInputStream("C\\User\\myUser\\logging.properties");
LogManager.getLogManager().readConfiguration(fis);

log.setLevel(LEVEL.INFO);
log.addHandler(new java.util.logging.consoleHandler());
log.setUseParentHandlers(false);

log.info("starting myApp");
fis.close();

} catch (Exception e) {
logger.log(Level.SEVERE, "Exception occurred", e);
}
}
}

 

This class is not able to send any log messages to splunk. Why?
I already tried to connect and send events manually with

 

URL url = new URL(SPLUNK_HEC_URL + "/services/collector/event");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Splunk " + SPLUNK_HEC_TOKEN);
connection.setDoOutput(true);
//....

 

and it was successful. but I want to make it work with the .properties approach.

Tags (2)
0 Karma

dural_yyz
Motivator

That level of JAVA support typically is beyond the Splunk community board.  These answer posts tend to focus on Splunk configurations.

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...