This rule detects the usage of the org.apache.juli.logging.Log and org.apache.juli.logging.LogFactory classes and methods. These logging methods are not available in WebSphere traditional or Liberty and must be migrated.
When an automated fix becomes available It will replace the org.apache.juli.logging.LogFactory with java.util.logging.Logger . It also replaces the Apache Tomcat logging methods with the Java Logger.log(Level, message) method.
Some of the Apache Tomcat methods map directly to a defined java.util.logging.Level . For the levels that do not map directly, you can customize the log level in the Analysis Configuration dialog.
The automated fix replacements are shown in this mapping table. Log methods that pass a Throwable as a second parameter are mapped in the same manner as their counterparts in the following table.
| org.apache.juli.logging method | java.util.logging method | Configurable |
|---|---|---|
| LogFactory.getLog(Class.class) | Logger.getLogger(Class.class.getName()) | No |
| LogFactory.getLog("log name") | Logger.getLogger("log name") | No |
| LogFactory.getInstance(Class.class) | Logger.getLogger(Class.class.getName()) | No |
| LogFactory.getInstance("log name") | Logger.getLogger("log name") | No |
| Log.fatal("mgs") | Logger.log(WsLevel.FATAL, "msg") | Yes |
| Log.error("msg") | Logger.log(Level.SEVERE, "msg") | Yes |
| Log.warn("msg") | Logger.log(Level.WARNING, "msg") | No |
| Log.info("msg") | Logger.log(Level.INFO, "msg") | No |
| Log.debug("msg") | Logger.log(WsLevel.DETAIL, "msg") | Yes |
| Log.trace("msg") | Logger.log(Level.FINE, "msg") | Yes |
For example, log class instance creation:
This example shows a call to org.apache.juli.logging.Log.error() with a Throwable as the second parameter.
org.apache.juli.logging.Log class
have parameters of type java.lang.Object.
The methods in the java.util.logging.Logger class have
parameters of type java.lang.String.
If you use parameters with types other than java.lang.String,
you might need to do additional manual migration to add
toString() to the parameters after running the automated fix
will migrate from org.apache.juli.logging.Log to
java.util.logging.Logger.
For additional information, see the following Java documentation: