Questions tagged [log4j2]

Log4j 2 is an upgrade to Log4j, a Java-based logging utility, that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture.

Log4j2 is a standalone upgrade to Log4j that provides significant improvements over its predecessor, Log4j 1.x, and provides many of the improvements available in Logback while fixing some inherent problems in Logback's architecture. Log4j2.x changes the API and is no longer downward compatible to log4j1.x

See Also

4386 questions
287
votes
4 answers

Very simple log4j2 XML configuration file using Console and File appender

I'd like a very simple XML configuration file with a console and a file appender using log4j2. (The Apache Website is killing me with much Information.)
Thorsten Niehues
  • 13,712
  • 22
  • 78
  • 113
184
votes
2 answers

Is it worth to use slf4j with log4j2

I am not able to decide whether to use slf4j or not with log4j2. Based on online posts, does not look like it will have any performance hit but is it really required. Also these points rule in favor of log4j2: SLF4J forces your application to log…
Andy897
  • 6,915
  • 11
  • 51
  • 86
149
votes
9 answers

Programmatically change log level in Log4j2

I'm interested in programmatically changing the log level in Log4j2. I tried looking at their configuration documentation but that didn't seem to have anything. I also tried looking in the package: org.apache.logging.log4j.core.config, but nothing…
CorayThan
  • 17,174
  • 28
  • 113
  • 161
97
votes
7 answers

Log4j2 configuration - No log4j2 configuration file found

Lately I decided to learn how to use the log4j2 logger. I downloaded required jar files, created library, xml comfiguration file and tried to use it. Unfortunately i get this statement in console (Eclipse) : ERROR StatusLogger No log4j2…
Qbisiek
  • 1,023
  • 2
  • 8
  • 8
96
votes
1 answer

What does “status” mean in Log4j2 configuration?

I just have finished adjustment of log4j2.xml configuration file and spotted something I don't really understand. So what is ? Almost in all examples here…
Yurii Bondarenko
  • 3,460
  • 6
  • 28
  • 47
78
votes
17 answers

No log4j2 configuration file found. Using default configuration: logging only errors to the console

$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar Written to the console, you get ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the…
Jeff Maass
  • 3,632
  • 3
  • 26
  • 30
77
votes
6 answers

Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to-slf4j

In my Spring boot 2 project: In build.gradle: dependencies { implementation 'com.google.code.gson:gson:2.7' implementation 'com.h2database:h2' implementation 'javax.servlet:jstl:1.2' implementation…
Alexei
  • 14,350
  • 37
  • 121
  • 240
74
votes
6 answers

Is log4j2 compatible with Java 11?

I tried to run my project on the latest Java 11. Everything works, except the specific file logger. Logging works fine on previous Java versions - 10, 9, 8, but not on Java 11. During server run I see only 1 warning: WARNING:…
Dmitriy Dumanskiy
  • 11,657
  • 9
  • 37
  • 57
62
votes
3 answers

How to Create a Custom Appender in log4j2?

As disscussed in this link : How to create a own Appender in log4j? For creating a custom appender in log4j 1.x we have to extend the AppenderSkeleton class and implements its append method. Similarly How we can create a custom appender in log4j2 as…
saurabh goyal
  • 1,754
  • 8
  • 35
  • 45
61
votes
3 answers

Log4j vulnerability - Is Log4j 1.2.17 vulnerable (was unable to find any JNDI code in source)?

With regard to the Log4j JNDI remote code execution vulnerability that has been identified CVE-2021-44228 - (also see references) - I wondered if Log4j-v1.2 is also impacted, but the closest I got from source code review is the JMS-Appender. The…
Ravindra HV
  • 2,558
  • 1
  • 17
  • 26
61
votes
10 answers

ERROR StatusLogger Log4j2 could not find a logging implementation

I am trying to implement log4j 2 but it keeps throwing the following error. > ERROR StatusLogger Log4j2 could not find a logging implementation. > Please add log4j-core to the classpath. Using SimpleLogger to log to > the console... > ERROR…
Alok
  • 1,441
  • 4
  • 20
  • 31
60
votes
2 answers

Log4J2 property substitution - default

I just wonder if there is any way to provide default value for property substitution in LOG4J? I want to pass file path in java system property and then use it with "${env:mySystemProperty}". But what if developer forgets to set this property? Then…
Leos Literak
  • 8,805
  • 19
  • 81
  • 156
58
votes
9 answers

log4j2 ERROR StatusLogger Unrecognized conversion specifier

I have log4j2 in my project when I run main method in intellij Idea ,it correct to print log. when i use maven-shade-plugin package project to jar file, and run jar as standalone application it shows error: java -cp package.jar…
CoderMeng
  • 739
  • 1
  • 6
  • 8
58
votes
2 answers

log4j2 specify relative path to tomcat home dir for FileAppender

I am trying to configure log4j2 for my tomcat server running locally. I am unable to pipe the logs to a location that is relative to the tomcat install. If I specify an absolute path it works. If I use a relative path it outputs to the location of…
Moemars
  • 4,692
  • 3
  • 27
  • 30
57
votes
2 answers

Log4j2 why would you use it over log4j?

I must be missing something but I have been looking at this for a few days now, but why on earth would you ever use log4j2 over log4j (other than the performance)? From what I have seen so far, log4j2 is advertised as simpler to configure, but its…
Scott Neville
  • 848
  • 1
  • 7
  • 14
1
2 3
99 100