Skip to content

Tag: log4j2

Log4j2 log file not created

For a spring-boot application I’m trying to set up a log4j2 logger that will write the logs into a few sperate files, but the logs are only written to the console, I’ve checked my user_dir to make sure I’m not looking in the wrong location as well. This is the code that should write the test logs: this is my

Unable to send the logs to Splunk Enterprise local using log4j2

I’m using log4j2 and splunk within java to send logs into my Splunk Enterprise HEC (HTTP Event Collector) Splunk Enterprise is running in my local machine. I’m doing all log4j2 configuration programmatically. (I know this is not the correct way to do this but I’m still doing this for learning purpose). I tried to send the logs into Splunk Enterprise

create a custom log4j2 rolling file appender

I want to create a custom log4j2 rolling file appender. I need to create this custom appender because I want to wrap the file name with current thread name. We are trying to migrate log4j 1.x to recent log4j2 version and previously we had used DailyRollingFileAppender to log all activities of our application. please find the below code. Here we

Why are log4j classes loaded by two class loaders?

I have a maven project for an application, which I run in a WildFly server. The project has log4j dependencies: I would like to get the LoggerContext like this: However, this results in ClassCastException: After some debugging, I have discovered that the problem is that the class LoggerContext is loaded via two different classloaders. How could this be possible? At

How to set log4j 2.x output path after reading in log4j.xml

Say I have an appender defined in the log4j.xml file below. How could I change the value “/home/logs/oarm_log.txt” to a different value that comes from a string found in the actual Java code so that the code determines where to output the .txt file? Answer Though your best go-to resource for this would be Log4j’s official documentation, I will list

Detecting Apache Log4j vulnerability presence in gradle transitive dependencies

There is a recent vulnerability in log4j which has criticality score of 10 How to check the presence of Log4j vulnerable versions in gradle so that it would list all the dependencies including the transitive dependencies? Answer We can use To list the dependency tree. It will list all dependencies with their respective version. Since this output can be

LOG4J2 RollingFile Appender not writing to file

I’m trying to configure log4j2 by code but my RollingFile and my custom plugin”JTxtLogAppender” not working. The problem with the RollingFile is that the log file is created but it not writing to the file, neither to my custom plugin, but output to console is working. Here my code: Answer Before all of the above code I execute and it