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 actually vastly more complicated (been three days now and I still cant get it to write a log in my home directory). The auto configuration simply does not work for me (or at least I cant get it to work), the configuration file itself is substantially more complex in its structure and appears to be much harder to add things in at runtime to help diagnose.
So other than the performance is there any reason to use log4j2 over original log4j?
Check this. In short, from the link:
As you said it's also much faster.
Disadvantages are:
log4j 2.0 is very different than log4j 1.x, and the API is mostly incompatible.
Difficult to set up.
If you don't need any of the new features, you're probably fine with the older Log4j 1.x.
Reasons to upgrade from Log4j 1.x to Log4j 2
Be aware
log4j-1.2-api
adapter but customizations that rely on Log4j 1.2 internals may not work.Tips when upgrading
Common issues people are having when getting started with log4j2:
log4j.configurationFile
system property<Configuration status="trace">
in the beginning of your config fileIf your problem is not one of the above, please show your config and provide more detail on what problem you are experiencing. (Not sure what you expect from auto-configuration, this is a very basic function that logs ERROR events to the console if log4j2 cannot find a configuration file. This will rarely be sufficient.)
To write to your home directory, you can use the system property lookup
${sys:PROPERTYNAME}
. Below is an example configuration to demonstrate: