Migrating to log4j2


With the 22.1 minor update 1 release, IBM Sterling® Order Management System uses log4j2 for the logging and does not ship the log4j v1.2.17.jar file.

The YFCLogCategory class that is primarily used for logging by the Sterling™ Order Management System code and also used by the customer code does not extend org.apache.log4j.Category, which is a log4j 1.x class. Your custom code is impacted with this release if you are using methods that are not defined by the YFCLogCategory class. Methods that are not defined by the YFCLogCategory class and are available from the org.apache.log4j.Category parent class, are not supported.

After you apply the 22.1 minor update 1 release, you can look at methods in the updated core Javadoc. The following methods are added to the YFCLogCategory class to ensure that no runtime failures of the custom code occur. However, these are dummy methods and might be removed in a later release.
  • public void log(Object level, Object obj)
  • public void setLevel(Object level)
  • public boolean isEnabledFor(Object level)
Custom code changes
Important:

The YFCLogCategory.getLogger() method is not supported. Use the YFCLogCategory.instance(Class.class) method instead.

For example,
private static YFCLogCategory logger = YFCLogCategory.instance(MyClassName.class);
Check your custom code and make the following changes:
  • If you are casting the YFCLogCategory instance to org.apache.log4j.Category or org.apache.log4j.Logger, it is not supported. Casting an instance of YFCLogCategory to org.apache.log4j.Logger or org.apache.log4j.Category does not compile when writing new code. For existing custom code that has these casts, the custom code encounters the ClassCastException at run time. For example, line #2 and #3 from the following code pattern are not supported.
    YFCLogCategory LOGGER = YFCLogCategory.instance(MyClass.class.getName());
    org.apache.log4j.Logger apLogger=(org.apache.log4j.Logger)LOGGER;          // Not supported
    org.apache.log4j.Category apCategory=(org.apache.log4j.Category)LOGGER;    // Not supported
  • If you are calling log(Level level, Object), replace it with specific methods such as error(Object) or debug(Object) that are provided by the YFCLogCategory class.
  • If you are calling setLevel(Level level), you must delete it. You cannot change levels of loggers in log4j2 because it is not supported in the log4j2 API. Further management of log levels is done by the code, and you must create traces for specific parts of the code for which you want extended logging.
  • If you are calling isEnabledFor(Level level), replace it with specific methods such as isInfoEnabled or isTimerEnabled.

Discontinuation of log4j-1.x jars

Any log4j-1.x jars are not supported in IBM Sterling Order Management System as part of the customer's customization package.

Discontinuation of log4j1 to log4j2 bridge jars

The log4j1 to log4j2 bridge jars are not supported. For example, adding log4j-1.2-api-2.17.1.jar to a customization package is not supported.

Third-party libraries

You must update your custom code or upgrade any third-party jars that still depend on log4j-1.x. Log4j-1.x is deprecated and is no longer supported by Apache. If you have third-party libraries that still require log4j 1.x, these are likely outdated libraries. You should migrate to the latest version of these third-party libraries or look for safer alternatives if the libraries are updated to use log4j2.