How to resolve a log4j class loading problem related to protected web services making use of Apache Log4j

Document ID : KB000022668
Last Modified Date : 14/02/2018
Show Technical Document Details


The SOA Agent for WebLogic uses the Apache log4j package to produce logging output. This can lead to class loading and logging output conflict problems when the SOA Agent is configured to protect web services that also use the log4j package.

If such a conflict is occurring WebLogic logs error output similar to the following:

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "o
rg.apache.log4j.Appender" variable.
log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
log4j:ERROR [] whereas object of type
log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [weblogic.utils.clas
sloaders.ChangeAwareClassLoader@10abd60 finder: weblogic.utils.classloaders.CodeGenClassFinder@5e33d4 annotation: StockTradeDemoDCC@StockTradeDemoDCC.war].
log4j:ERROR Could not instantiate appender named "CUSTOMER_APPENDER_NAME".


This error is caused by the web service class loader loading the specific Appender implementation class: DailyRollingFileAppender and the SOA Agent class loader loading the Appender interface class.


Configure the system class loader to load the log4j jar instead of the SOA Agent and web service class loaders by adding log4j.jar to the JVM classpath.

To configure the system class loader to load the log4j package

  1. Add WLS_HOME/weblogicXY/server/lib/log4j.jar to the classpath variable passed into the Java Virtual Machine at startup.

    For a WebLogic Server running as a command line application, make this change by editing the startWeblogic.cmd (Windows) or (UNIX) script located in WLS_HOME/user_projects/domains/your_domain/bin.

  2. Rename the SOA Agent log4j.jar to prevent it from being loaded:

    1. Navigate to SOA_HOME/wlsagent/lib/thirdparty.

    2. Rename log4j.jar to log4j.jar_hidden.

  3. For each protected web service that also uses the log4j package, rename log4j.jar to prevent it from being loaded:

    1. Navigate to the directory that contains the log4j.jar file used by the web service.

    2. Rename log4j.jar to log4j.jar_hidden.

  4. Modify the XML message processing logging configuration:

    1. Navigate to SOA_HOME/wlsagent/config

    2. Open the log.config file in text editor.

    3. Locate the line that defines the parameter. For example:

    4. Append an explicit reference to the Message Processing Appender also declared in the log.config file. For example, if the name of the Daily Rolling File Appender is "A2", the parameter definition line becomes:, A2