USEPA / emf

Emissions Modeling Framework (EMF)
6 stars 3 forks source link

Update or remove log4j from client #108

Open cseppan opened 2 years ago

cseppan commented 2 years ago

Message seen when running the EMF Client

Upgrade to Apache Log4j version 2.16.0 or later since 1.x is end of life.

Check if log4j library is needed for client and remove if not needed. If library is removed, check if EMF Client Installer removes the jar file when run (installer probably doesn't have this feature so will need a new issue to add it).

cseppan commented 2 years ago

More info about how Log4j is used in the EMF:

The EMF uses Apache Commons Logging which works with different logging implementations. The EMF server component uses Log4j as the logging implementation by including the log4j jar and a log4j.properties file in the WAR archive. A typical usage is:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DataServiceImpl implements DataService {
    private static Log LOG = LogFactory.getLog(DataServiceImpl.class);

    public void archiveDataset() {
        try {
            ....
        } catch (Exception e) {
            LOG.error("Error archiving dataset", e);
            throw new EmfException(e.getMessage());
        }

On the server, the log4j.properties file adds formatting to the log messages that are written to Tomcat's catalina.out log file and also creates rolling logs in the user's home directory (emf.log, emf-rolling.log).

While the EMF Client has a very few direct uses of LogFactory and includes the log4j jar file, there's no log4j.properties file so Log4j isn't actually used. On startup, warnings are printed to stderr:

Starting EMF Client
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Removing the log4j jar from the lib/ directory doesn't cause any problems for running the EMF Client.

cseppan commented 2 years ago

The EMF Client Installer program will delete outdated files. The installer keeps track of the existing list of files in the update.dat archive and compares it to the freshly downloaded list in files.txt. Any out-of-date files are deleted. The installer also rewrites the EMFClient.bat file and updates the classpath each time the installer is run.