I am trying to configure asynchronous logging (for performance reasons) as part of the REST web methods that are currently running on the freedom profile server.
To do this, I created the following property:
System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
My problem is that no matter where I do it, sometimes it works, and registration is very fast, and sometimes not.
I tried (a) in the constructor for a class containing all the web REST methods (b) in the filter doFilter method, which is called before the REST method (c) in the filter initialization method (d) in the REST method itself
None of these places work in sequence.
Can anyone suggest an explanation for this behavior and, if possible, a suggested way to fix the problem.
EDIT: It seems that log4j is initialized before calling setProperty. So what I need to do is configure the property through the freedom profile.
source share