Apama 10.15.0 | Release Notes | What's New In Apama 10.5.0 | Change of Java Log4j logging library in 10.5.0
 
Change of Java Log4j logging library in 10.5.0
The correlator, the IAF, the dashboard servers, and the com.apama.util.Logger class used by the Java client library now use Log4j 2 rather than Log4j 1.
In Software AG Designer, Apama projects with a Java nature now use Log4j 2. If you are still using Log4j 1.2, you must now upgrade your applications to use Log4j 2 or manually add the Log4j-1-to-2 bridge or the Log4j-1-to-SLF4J bridge to your classpath from common/lib/ext/log4j.
In Log4j 2, the configuration file format, the system property that specifies the configuration file location, and the Java package are all completely different to Log4j 1. So if your application directly uses the Log4j 1 API (org.apache.log4j.*) or you have any custom Log4j configuration files (for example, a log4j.properties file), you will need to change them when upgrading to this Apama release. See the Log4j website at https://logging.apache.org/log4j/2.x/ for detailed information on Log4j 1.x migration.
The Log4j 1.2 configuration files are no longer used. Thus, the log4jConfigFile configuration option for controlling the verbosity, which was previously used by the Kafka and Digital Event Services transports, is no longer supported in an Apama project. If you are using the log4jConfigFile configuration option, you should now set the log levels in the YAML configuration file for the correlator instead, using the correlatorLogging entry. See also Setting correlator and plug-in log files and log levels in a YAML configuration file.
If you are using com.apama.util.Logger within the correlator or IAF processes, no changes should be required. However, if you use com.apama.util.Logger in a standalone Java application, perhaps using the Apama Engine Client or Scenario Service APIs, you will need to provide a Log4j 2 configuration file even if previously you did not, as the com.apama.util.Logger class no longer performs automatic configuration of Log4j. Again, see the Log4j website for sample configuration files and detailed information on the configuration file format.
You may also need to take action if you use a third-party library inside the correlator that itself performs logging, for example, a connectivity plug-in, EPL plug-in, or JMS client library. The correlator's root classloader now contains Log4j 2, the widely-used SLF4J logging facade, and the Log4j 2 SLF4J implementation binding. So any libraries using SLF4J or Log4j 2 will correctly write to the correlator log file automatically, and their log levels can be customized using correlatorLogging in the YAML configuration file (as described in Setting correlator and plug-in log files and log levels in a YAML configuration file). The root classloader also contains the Log4j 1.x bridge (log4j-1.2-api.jar) which redirects calls to most of the Log4j 1 API through to Log4j 2, so provided you do not use internal features such as programmatic configuration, Log4j 1 libraries should work fine. However, we recommend that you transition away from Log4j 1 since it has reached end-of-life status. If some other logging library is used which does not support SLF4J directly, you should add a jar that bridges from that library's API to SLF4J or Log4j2 if possible.
Previous Apama versions included the jars for Log4j 1 and SLF4J in the lib directory of your Apama installation. In this release, the SLF4J and Log4j logging jars are now located in the Software AG installation directory under common/lib/ext and common/lib/ext/log4j. Any build scripts (for example, Apache Ant build.xml scripts) that need these jars at compilation time should be updated to point to the new location.
The IAF-based Web Services Client adapter now writes some of its logging output to standard output rather than to a hardcoded file called iaf.log as in the previous version, though the messages written to standard output are likely to be useful only for debugging purposes. This behavior can be customized in APAMA_HOME\adapters\config\log4j-iaf.xml if needed. If you have an existing configuration, you should edit the WebServicesClientAdapter.xml file in your project to use the Log4j 2 configuration file and system property instead of the old log4j.configuration property:
<property name="log4j.configurationFile" value="file:///@APAMA_HOME@/adapters/config/log4j-iaf.xml"/>